I search for a good way to copy a file (binary or text). I\'ve written several samples, everyone works. But I want hear the opinion of seasoned programmers.
I missin
Copy a file in a sane way:
#include
int main()
{
std::ifstream src("from.ogv", std::ios::binary);
std::ofstream dst("to.ogv", std::ios::binary);
dst << src.rdbuf();
}
This is so simple and intuitive to read it is worth the extra cost. If we were doing it a lot, better to fall back on OS calls to the file system. I am sure boost
has a copy file method in its filesystem class.
There is a C method for interacting with the file system:
#include
int
copyfile(const char *from, const char *to, copyfile_state_t state, copyfile_flags_t flags);