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;
}