diff options
author | Ekaterina Vaartis <vaartis@cock.li> | 2018-01-11 17:04:29 +0000 |
---|---|---|
committer | Ekaterina Vaartis <vaartis@cock.li> | 2018-01-11 17:04:29 +0000 |
commit | e44cbaf7047e0545dd3088a4ac0486ef67eec314 (patch) | |
tree | 83d5fa401e89555fc25cb86ef6928f4c845a500d /libcxx/src/experimental/filesystem/operations.cpp | |
parent | 8de035670ec676da68e08167bde74c28440322ec (diff) | |
download | bcm5719-llvm-e44cbaf7047e0545dd3088a4ac0486ef67eec314.tar.gz bcm5719-llvm-e44cbaf7047e0545dd3088a4ac0486ef67eec314.zip |
Make std::experimental::filesystem::remove and remove_all return false or 0 if the file doesn't exist
Differential Revision: https://reviews.llvm.org/D41830
llvm-svn: 322293
Diffstat (limited to 'libcxx/src/experimental/filesystem/operations.cpp')
-rw-r--r-- | libcxx/src/experimental/filesystem/operations.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libcxx/src/experimental/filesystem/operations.cpp b/libcxx/src/experimental/filesystem/operations.cpp index 662fa7b8626..91aee6ffbcb 100644 --- a/libcxx/src/experimental/filesystem/operations.cpp +++ b/libcxx/src/experimental/filesystem/operations.cpp @@ -661,8 +661,10 @@ path __read_symlink(const path& p, std::error_code *ec) { bool __remove(const path& p, std::error_code *ec) { if (ec) ec->clear(); + if (::remove(p.c_str()) == -1) { - set_or_throw(ec, "remove", p); + if (errno != ENOENT) + set_or_throw(ec, "remove", p); return false; } return true; @@ -692,13 +694,18 @@ std::uintmax_t remove_all_impl(path const & p, std::error_code& ec) } // end namespace std::uintmax_t __remove_all(const path& p, std::error_code *ec) { + if (ec) ec->clear(); + std::error_code mec; auto count = remove_all_impl(p, mec); if (mec) { - set_or_throw(mec, ec, "remove_all", p); - return static_cast<std::uintmax_t>(-1); + 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); + } } - if (ec) ec->clear(); return count; } |