mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
#4: Removed range-based for-loops with fs::directory_iterator in error_code versions of fs::copy and fs::remove_all as they are compatible with "noexcet".
This commit is contained in:
parent
974c9bd1a0
commit
8cddfcbf7b
17
filesystem.h
17
filesystem.h
@ -2812,8 +2812,10 @@ inline void copy(const path& from, const path& to, copy_options options, std::er
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const directory_entry& x : directory_iterator(from, ec)) {
|
for (auto iter = directory_iterator(from, ec); iter != directory_iterator(); iter.increment(ec)) {
|
||||||
copy(x.path(), to / x.path().filename(), options | static_cast<copy_options>(0x8000), ec);
|
if(!ec) {
|
||||||
|
copy(iter->path(), to / iter->path().filename(), options | static_cast<copy_options>(0x8000), ec);
|
||||||
|
}
|
||||||
if(ec) {
|
if(ec) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3688,15 +3690,18 @@ inline uintmax_t remove_all(const path& p, std::error_code& ec) noexcept
|
|||||||
ec = detail::make_error_code(detail::portable_error::not_supported);
|
ec = detail::make_error_code(detail::portable_error::not_supported);
|
||||||
return static_cast<uintmax_t>(-1);
|
return static_cast<uintmax_t>(-1);
|
||||||
}
|
}
|
||||||
for (const directory_entry& de : directory_iterator(p, ec)) {
|
for (auto iter = directory_iterator(p, ec); iter != directory_iterator(); iter.increment(ec)) {
|
||||||
if (!de.is_symlink() && de.is_directory()) {
|
if(ec) {
|
||||||
count += remove_all(de.path(), ec);
|
break;
|
||||||
|
}
|
||||||
|
if (!iter->is_symlink() && iter->is_directory()) {
|
||||||
|
count += remove_all(iter->path(), ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
return static_cast<uintmax_t>(-1);
|
return static_cast<uintmax_t>(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
remove(de.path(), ec);
|
remove(iter->path(), ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
return static_cast<uintmax_t>(-1);
|
return static_cast<uintmax_t>(-1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user