-
- Downloads
libstdc++: Fix overwriting files with fs::copy_file on Windows
There are no inode numbers on Windows filesystems, so stat_type::st_ino is always zero and the check for equivalent files in do_copy_file was incorrectly identifying distinct files as equivalent. This caused copy_file to incorrectly report errors when trying to overwrite existing files. The fs::equivalent function already does the right thing on Windows, so factor that logic out into a new function that can be reused by fs::copy_file. The tests for fs::copy_file were quite inadequate, so this also adds checks for that function's error conditions. libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc (auto_win_file_handle): Change constructor parameter from const path& to const wchar_t*. (fs::equiv_files): New function. (fs::equivalent): Use equiv_files. * src/filesystem/ops-common.h (fs::equiv_files): Declare. (do_copy_file): Use equiv_files. * src/filesystem/ops.cc (fs::equiv_files): Define. (fs::copy, fs::equivalent): Use equiv_files. * testsuite/27_io/filesystem/operations/copy.cc: Test overwriting directory contents recursively. * testsuite/27_io/filesystem/operations/copy_file.cc: Test overwriting existing files.
Showing
- libstdc++-v3/src/c++17/fs_ops.cc 43 additions, 28 deletionslibstdc++-v3/src/c++17/fs_ops.cc
- libstdc++-v3/src/filesystem/ops-common.h 9 additions, 3 deletionslibstdc++-v3/src/filesystem/ops-common.h
- libstdc++-v3/src/filesystem/ops.cc 16 additions, 2 deletionslibstdc++-v3/src/filesystem/ops.cc
- libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc 9 additions, 0 deletionslibstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
- libstdc++-v3/testsuite/27_io/filesystem/operations/copy_file.cc 122 additions, 0 deletions...c++-v3/testsuite/27_io/filesystem/operations/copy_file.cc
Loading
Please register or sign in to comment