From 26077f272e7c63af5747fac3aafed96ce7fb988b Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Fri, 6 Mar 2020 09:19:46 +0100 Subject: [PATCH] refs #54, directory_entry methods now reset error_code, when returning cached result --- README.md | 4 ++++ include/ghc/filesystem.hpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 94d1c69..8e00222 100644 --- a/README.md +++ b/README.md @@ -486,6 +486,10 @@ to the expected behavior. ### v1.3.1 (wip) +* Bugfix for [#55](https://github.com/gulrak/filesystem/issues/55), `fs::create_directories` + returned `true` when nothing needed to be created, because the directory already existed. +* Bugfix for [#54](https://github.com/gulrak/filesystem/issues/54), `error_code` + was not reset, if cached result was returned. * Pull request [#53](https://github.com/gulrak/filesystem/pull/53), fix for wrong handling of leading whitespace when reading `fs::path` from a stream. * Pull request [#52](https://github.com/gulrak/filesystem/pull/52), an ARM Linux diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 300a645..7951369 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -4649,6 +4649,7 @@ GHC_INLINE uintmax_t directory_entry::file_size() const GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { + ec.clear(); return _file_size; } return filesystem::file_size(path(), ec); @@ -4668,6 +4669,7 @@ GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const { #ifndef GHC_OS_WINDOWS if (_status.type() != file_type::none) { + ec.clear(); return _hard_link_count; } #endif @@ -4685,6 +4687,7 @@ GHC_INLINE file_time_type directory_entry::last_write_time() const GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { + ec.clear(); return std::chrono::system_clock::from_time_t(_last_write_time); } return filesystem::last_write_time(path(), ec); @@ -4701,6 +4704,7 @@ GHC_INLINE file_status directory_entry::status() const GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { + ec.clear(); return _status; } return filesystem::status(path(), ec); @@ -4717,6 +4721,7 @@ GHC_INLINE file_status directory_entry::symlink_status() const GHC_INLINE file_status directory_entry::symlink_status(std::error_code& ec) const noexcept { if (_symlink_status.type() != file_type::none) { + ec.clear(); return _symlink_status; } return filesystem::symlink_status(path(), ec);