What is the difference between std::filesystem::copy()
and std::filesystem::copy_file()
in this code?
#include <filesystem>
void testing()
{
const std::filesystem::path src = "foo.txt";
const std::filesystem::path dst = "bar.txt";
std::filesystem::copy( src, dst, std::filesystem::copy_options::overwrite_existing);
std::filesystem::copy_file(src, dst, std::filesystem::copy_options::overwrite_existing);
}
Docs say:
copy()
: "copies files or directories"copy_file()
: "copies file contents"
Since I'm copying a single file and not directories in this example, are these two calls the same?
(I'm using g++ 8.2.0. Remember to link against libstdc++fs otherwise you'll have undefined references to std::filesystem.)