diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-31 13:52:41 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-31 13:52:41 +0200 |
commit | decd319bc1bc7d427f92feba29d408eb2edb973d (patch) | |
tree | ee8195bc563a58161f8e0c4ae8ce601f3f8a4a58 /butl/filesystem.ixx | |
parent | 32e8dbc3558a7b9ddecad50a9eb241b5e36f6c02 (diff) |
Add rmdir_r(), path_permissions()
Diffstat (limited to 'butl/filesystem.ixx')
-rw-r--r-- | butl/filesystem.ixx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/butl/filesystem.ixx b/butl/filesystem.ixx index 2d2690f..256cbba 100644 --- a/butl/filesystem.ixx +++ b/butl/filesystem.ixx @@ -4,6 +4,35 @@ namespace butl { + inline rmdir_status + try_rmdir_r (const dir_path& p) + { + bool e (dir_exists (p)); //@@ What if it exists but is not a directory? + + if (e) + rmdir_r (p); + + return e ? rmdir_status::success : rmdir_status::not_exist; + } + + // permissions + // + inline permissions operator& (permissions x, permissions y) {return x &= y;} + inline permissions operator| (permissions x, permissions y) {return x &= y;} + inline permissions operator&= (permissions& x, permissions y) + { + return x = static_cast<permissions> ( + static_cast<std::uint16_t> (x) & + static_cast<std::uint16_t> (y)); + } + + inline permissions operator|= (permissions& x, permissions y) + { + return x = static_cast<permissions> ( + static_cast<std::uint16_t> (x) | + static_cast<std::uint16_t> (y)); + } + // dir_entry // inline entry_type dir_entry:: |