[PATCH] D41830: [libc++] Fix PR#35780 - make std::experimental::filesystem::remove and remove_all return false or 0 if the file doesn't exist
Marshall Clow via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 9 11:10:55 PST 2018
mclow.lists added inline comments.
================
Comment at: src/experimental/filesystem/operations.cpp:699
auto count = remove_all_impl(p, mec);
if (mec) {
+ if (mec != errc::no_such_file_or_directory) {
----------------
I don't think that this is quite right, either.
In the case where you call `remove_all("doesNotExist", &ec)`, this code will return 0, but will fail to clear `ec`.
Maybe this (untested) version instead:
if (ec) ec->clear();
auto count = remove_all_impl(p, mec);
if (mec) {
if (mec == errc::no_such_file_or_directory)
return 0;
else {
set_or_throw(mec, ec, "remove_all", p);
return static_cast<std::uintmax_t>(-1);
}
}
return count;
https://reviews.llvm.org/D41830
More information about the cfe-commits
mailing list