mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
Fix ghc::filesystem::remove_all behavior if argument is symlink
This commit is contained in:
parent
6a835afddf
commit
1f3943b1c4
@ -4740,7 +4740,7 @@ GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept
|
||||
return static_cast<uintmax_t>(-1);
|
||||
}
|
||||
std::error_code tec;
|
||||
auto fs = status(p, tec);
|
||||
auto fs = symlink_status(p, tec);
|
||||
if (exists(fs) && is_directory(fs)) {
|
||||
for (auto iter = directory_iterator(p, ec); iter != directory_iterator(); iter.increment(ec)) {
|
||||
if (ec && !detail::is_not_found_error(ec)) {
|
||||
|
@ -2607,6 +2607,10 @@ TEST_CASE("fs.op.remove_all - remove_all", "[filesystem][operations][fs.op.remov
|
||||
CHECK_NOTHROW(fs::remove_all("dir1/non-existing", ec));
|
||||
CHECK(!ec);
|
||||
CHECK(fs::remove_all("dir1/non-existing", ec) == 0);
|
||||
if (is_symlink_creation_supported()) {
|
||||
fs::create_directory_symlink("dir1", "dir1link");
|
||||
CHECK(fs::remove_all("dir1link") == 1);
|
||||
}
|
||||
CHECK(fs::remove_all("dir1") == 5);
|
||||
CHECK(fs::directory_iterator(t.path()) == fs::directory_iterator());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user