The following program throws if the regular file "bar" already exist with
terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
what(): filesystem error: cannot copy file: File exists [foo] [bar]
This does not happen under linux and also not under cygwin as I have been told. So I guess it could be an msys2 issue.
#include <filesystem>
int main() {
std::filesystem::copy_file("foo","bar",std::filesystem::copy_options::overwrite_existing);
}
If "bar" does not exist yet, the copying succeeds. I use an up to date msys2 64bit system.
MSYS2 gcc 10.1.0, bug reproduced
Yeah, I'm getting the same bug, 10.1.0, regardless of copy_options passed.
Similar error with copy (msys2/g++ 10.2.0):
#include <filesystem>
int main() {
std::filesystem::copy("fooDir", "barDir", std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive);
return 0;
}
If "barDir" does not exist yet, the copying succeeds. Otherwise, I've got this error:
terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
what(): filesystem error: cannot copy: File exists [fooDir] [barDir]
Most helpful comment
Yeah, I'm getting the same bug, 10.1.0, regardless of copy_options passed.