From 036cf96bb60cc8d60febd049fe63b0c562983776 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Wed, 6 Mar 2019 07:05:10 +0100 Subject: [PATCH] additions to changes for #6, don't count removal of non-existing files --- filesystem.h | 6 ++++-- test/filesystem_test.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/filesystem.h b/filesystem.h index e387442..6cd936c 100644 --- a/filesystem.h +++ b/filesystem.h @@ -3712,12 +3712,14 @@ inline uintmax_t remove_all(const path& p, std::error_code& ec) noexcept } } if(!ec) { - remove(p, ec); + if(remove(p, ec)) { + ++count; + } } if (ec) { return static_cast(-1); } - return ++count; + return count; } inline void rename(const path& from, const path& to) diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 11d5276..04ffce0 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -2028,6 +2028,7 @@ TEST_CASE("30.10.15.31 remove_all", "[filesystem][operations][fs.op.remove_all]" generateFile("dir1/dir1b/f2"); CHECK_NOTHROW(fs::remove_all("dir1/non-existing", ec)); CHECK(!ec); + CHECK(fs::remove_all("dir1/non-existing", ec) == 0); CHECK(fs::remove_all("dir1") == 5); CHECK(fs::directory_iterator(t.path()) == fs::directory_iterator()); }