mirror of git://gcc.gnu.org/git/gcc.git
libstdc++: Fix error reporting for filesystem::rename on Windows [PR122726]
Use the __last_system_error() function and the system_category to convert the Windows error to a generic one. libstdc++-v3/ChangeLog: PR libstdc++/122726 * src/filesystem/ops-common.h [_GLIBCXX_FILESYSTEM_IS_WINDOWS] (rename): Use __last_system_error to set errno accurately. * testsuite/27_io/filesystem/operations/rename.cc: Test error_code matches errc::no_such_file_or_directory.
This commit is contained in:
parent
61f154cfe1
commit
77278e0292
|
|
@ -159,10 +159,7 @@ namespace __gnu_posix
|
||||||
if (MoveFileExW(oldname, newname,
|
if (MoveFileExW(oldname, newname,
|
||||||
MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
|
MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
|
||||||
return 0;
|
return 0;
|
||||||
if (GetLastError() == ERROR_ACCESS_DENIED)
|
errno = std::__last_system_error().default_error_condition().value();
|
||||||
errno = EACCES;
|
|
||||||
else
|
|
||||||
errno = EIO;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,10 +170,20 @@ test_directories()
|
||||||
fs::remove_all(dir, ec);
|
fs::remove_all(dir, ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_pr122726()
|
||||||
|
{
|
||||||
|
std::error_code ec;
|
||||||
|
const auto nonesuch = __gnu_test::nonexistent_path();
|
||||||
|
fs::rename(nonesuch, "new-name", ec);
|
||||||
|
VERIFY( ec == std::make_error_code(std::errc::no_such_file_or_directory) );
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
test_symlinks();
|
test_symlinks();
|
||||||
test_directories();
|
test_directories();
|
||||||
|
test_pr122726();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue