summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-07-25 04:46:32 +0000
committerEric Fiselier <eric@efcs.ca>2018-07-25 04:46:32 +0000
commit8410c8170ae75364dfb2891cc9be89aa4ba8ea41 (patch)
tree2de02b567801985015e3b686d1b01347538937cd /src
parentbb00305f46be91557039e55e9a61b358e08c4c36 (diff)
downloadlibcxx-8410c8170ae75364dfb2891cc9be89aa4ba8ea41.tar.gz
Fix bugs in create_directory implementation.
Libc++ was incorrectly reporting an error when the target of create_directory already exists, but was not a directory. This behavior is not specified in the most recent standard, which says no error should be reported. Additionally, libc++ failed to report an error when the attribute directory path didn't exist or didn't name a directory. This has been fixed as well. Although it's not clear if we should call status or symlink_status on the attribute directory. This patch chooses to still call status. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src')
-rw-r--r--src/experimental/filesystem/operations.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/experimental/filesystem/operations.cpp b/src/experimental/filesystem/operations.cpp
index 089e34b20..dd8b43477 100644
--- a/src/experimental/filesystem/operations.cpp
+++ b/src/experimental/filesystem/operations.cpp
@@ -830,7 +830,7 @@ bool __create_directory(const path& p, error_code *ec)
if (::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)
return true;
- if (errno != EEXIST || !is_directory(p))
+ if (errno != EEXIST)
err.report(capture_errno());
return false;
}
@@ -845,10 +845,12 @@ bool __create_directory(path const & p, path const & attributes,
auto st = detail::posix_stat(attributes, attr_stat, &mec);
if (!status_known(st))
return err.report(mec);
+ if (!is_directory(st))
+ return err.report(errc::not_a_directory, "the specified attribute path is invalid");
if (::mkdir(p.c_str(), attr_stat.st_mode) == 0)
return true;
- if (errno != EEXIST || !is_directory(p))
+ if (errno != EEXIST)
err.report(capture_errno());
return false;
}