Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:42:15+00:00 2026-06-12T13:42:15+00:00

Possible Duplicate: Copy a file in an sane, safe and efficient way I’ve searched

  • 0

Possible Duplicate:
Copy a file in an sane, safe and efficient way

I’ve searched for similar topics, but I couldn’t find the answer for large binary files. Considering that I have very large binary files (like ~10 or ~100 GB each), how do I copy them with the following function, using standard C++ (no POSIX functions) :

bool copy(const std::string& oldName, const std::string& newName)
{
    /* SOMETHING */
}

EDIT :
Is the following implementation ok ? (adapted from the link in comments)

bool copy(const std::string& oldName, const std::string& newName)
{
    bool ok = false;
    std::ifstream oldStream(oldName.c_str(), std::ios::binary);
    std::ofstream newStream(newName.c_str(), std::ios::binary);
    if (oldStream.is_open() && newStream.is_open()) {
        newStream << oldStream.rdbuf();
        ok = (oldStream.good() && newStream.good());
    }
    return ok;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:42:17+00:00Added an answer on June 12, 2026 at 1:42 pm

    You may use std::fopen, std::fread, std::fwrite, and std::fclose, all of which are part of the standard C++ library (#include <cstdio>, very portable) and won’t mess up binary data as long as you don’t use a "t" specifier to fopen.

    It will even be reasonably quick if you pick an appropriate buffer size (say 1 mebibyte) that gets you into the realm of sequential I/O performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Best way to copy the entire contents of a directory in C#
Possible Duplicate: How to copy a file to another path? hi, how to copy
Possible Duplicate: Warning: The Copy Bundle Resources build phase contains this target's Info.plist file
Possible Duplicate: Copy to Output Directory copies folder structure but only want to copy
Possible Duplicate: What's the best way to make a deep copy of a data
Possible Duplicate: What is the best way to clone/deep copy a .NET generic Dictionary<string,
Possible Duplicate: What's the most reliable way to prohibit a copy constructor in C++?
Possible Duplicate: What's the best way to make a deep copy of a data
Possible Duplicate: Is it possible to copy database file to SD card? I have
Possible Duplicate: Extracting text from HTML file using Python What is the best way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.