diff options
Diffstat (limited to 'libstdc++-v3/src/filesystem/ops.cc')
-rw-r--r-- | libstdc++-v3/src/filesystem/ops.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index aa26cafa103..5b82088891e 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -220,8 +220,9 @@ fs::canonical(const path& p, const path& base) { error_code ec; path can = canonical(p, base, ec); - if (ec.value()) - _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot canonicalize", p, ec)); + if (ec) + _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot canonicalize", p, base, + ec)); return can; } @@ -449,7 +450,7 @@ namespace ec = std::make_error_code(std::errc::io_error); return false; } - if (sbout.close() || sbin.close()) + if (!sbout.close() || !sbin.close()) { ec.assign(errno, std::generic_category()); return false; @@ -659,22 +660,26 @@ namespace bool create_dir(const fs::path& p, fs::perms perm, std::error_code& ec) { + bool created = false; #ifdef _GLIBCXX_HAVE_SYS_STAT_H ::mode_t mode = static_cast<std::underlying_type_t<fs::perms>>(perm); if (::mkdir(p.c_str(), mode)) { - ec.assign(errno, std::generic_category()); - return false; + const int err = errno; + if (err != EEXIST || !is_directory(p)) + ec.assign(err, std::generic_category()); + else + ec.clear(); } else { ec.clear(); - return true; + created = true; } #else ec = std::make_error_code(std::errc::not_supported); - return false; #endif + return created; } } // namespace |