diff options
author | Eric Fiselier <eric@efcs.ca> | 2018-03-26 06:23:55 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2018-03-26 06:23:55 +0000 |
commit | 4d334c4cdd4a58dc930cbc2ed8abd77f1a1cd4bb (patch) | |
tree | 13bfb051f3cbba61779e40e82e8eaf73f8feec40 /libcxx/src | |
parent | 19aae8fe2f2a5dfaaa7b6f2631f3f86801fc832d (diff) | |
download | bcm5719-llvm-4d334c4cdd4a58dc930cbc2ed8abd77f1a1cd4bb.tar.gz bcm5719-llvm-4d334c4cdd4a58dc930cbc2ed8abd77f1a1cd4bb.zip |
Implement filesystem::perm_options specified in NB comments.
The NB comments for filesystem changed permissions and added
a new enum `perm_options` which control how the permissions
are applied.
This implements than NB resolution
llvm-svn: 328476
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/experimental/filesystem/operations.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libcxx/src/experimental/filesystem/operations.cpp b/libcxx/src/experimental/filesystem/operations.cpp index bd173893ca4..b52022ac3f2 100644 --- a/libcxx/src/experimental/filesystem/operations.cpp +++ b/libcxx/src/experimental/filesystem/operations.cpp @@ -178,7 +178,7 @@ bool copy_file_impl(const path& from, const path& to, perms from_perms, ec, "copy_file", from, to); return false; } - __permissions(to, from_perms, ec); + __permissions(to, from_perms, perm_options::replace, ec); // TODO what if permissions fails? return true; } @@ -635,14 +635,17 @@ void __last_write_time(const path& p, file_time_type new_time, } -void __permissions(const path& p, perms prms, std::error_code *ec) +void __permissions(const path& p, perms prms, perm_options opts, + std::error_code *ec) { - - const bool resolve_symlinks = !bool(perms::symlink_nofollow & prms); - const bool add_perms = bool(perms::add_perms & prms); - const bool remove_perms = bool(perms::remove_perms & prms); - _LIBCPP_ASSERT(!(add_perms && remove_perms), - "Both add_perms and remove_perms are set"); + auto has_opt = [&](perm_options o) { return bool(o & opts); }; + const bool resolve_symlinks = !has_opt(perm_options::nofollow); + const bool add_perms = has_opt(perm_options::add); + const bool remove_perms = has_opt(perm_options::remove); + _LIBCPP_ASSERT( + (add_perms + remove_perms + has_opt(perm_options::replace)) == 1, + "One and only one of the perm_options constants replace, add, or remove " + "is present in opts"); bool set_sym_perms = false; prms &= perms::mask; |