
Jonathan Wakely <cow@compsoc.man.ac.uk> writes: | Looking at the implementation of copy_file() I'm wondering why it isn't | done like this (this provides noclobber support too):
| std::fstream out; | if (noclobber) | { | out.open(to_file_ph.string().c_str(), std::ios::in); wouldn't a exists work equally well? (a bit less heavyweight perhaps) | if (out.is_open()) | { | // file exists | boost::throw_exception( filesystem_error( | "boost::filesystem::copy_file", | from_file_ph, to_file_ph, fs::detail::system_error_code() ) ); | } | } | std::ifstream in(from_file_ph.string().c_str()); | out.open(to_file_ph.string().c_str(), std::ios::out); Add std::ios::trunc here and we are in violent agreement. | out << in.rdbuf();
| It may not be blindingly fast on all systems (though there's no reason | it can't be, with a good filebuf) Might be that the code could work directly on filebuf as well. -- Lgb