diff options
author | Eric Fiselier <eric@efcs.ca> | 2018-07-25 04:46:32 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2018-07-25 04:46:32 +0000 |
commit | 84e48004cf7e2a9827cd025d35719808a699ed27 (patch) | |
tree | 6b42345a1473adb372b30666efb71a09d1aaadc3 /libcxx/src/experimental/filesystem/operations.cpp | |
parent | 6508929da9b2d7729f0047ce798fd648e3d63c3a (diff) | |
download | bcm5719-llvm-84e48004cf7e2a9827cd025d35719808a699ed27.tar.gz bcm5719-llvm-84e48004cf7e2a9827cd025d35719808a699ed27.zip |
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.
llvm-svn: 337888
Diffstat (limited to 'libcxx/src/experimental/filesystem/operations.cpp')
-rw-r--r-- | libcxx/src/experimental/filesystem/operations.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libcxx/src/experimental/filesystem/operations.cpp b/libcxx/src/experimental/filesystem/operations.cpp index 089e34b203b..dd8b4347774 100644 --- a/libcxx/src/experimental/filesystem/operations.cpp +++ b/libcxx/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; } |