diff options
Diffstat (limited to 'libbutl/filesystem.ixx')
-rw-r--r-- | libbutl/filesystem.ixx | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/libbutl/filesystem.ixx b/libbutl/filesystem.ixx index 8cd8456..b3f9224 100644 --- a/libbutl/filesystem.ixx +++ b/libbutl/filesystem.ixx @@ -1,6 +1,9 @@ // file : libbutl/filesystem.ixx -*- C++ -*- // license : MIT; see accompanying LICENSE file +#include <libbutl/utility.hxx> // operator<<(ostream,exception), + // throw_generic_error() + namespace butl { inline bool @@ -8,7 +11,7 @@ namespace butl { // @@ Could 0 size be a valid and faster way? // - return dir_iterator (d, false /* ignore_dangling */) == dir_iterator (); + return dir_iterator (d, dir_iterator::no_follow) == dir_iterator (); } inline bool @@ -70,7 +73,7 @@ namespace butl // template <typename P> inline auto_rm<P>:: - auto_rm (auto_rm&& x) + auto_rm (auto_rm&& x) noexcept : path (std::move (x.path)), active (x.active) { x.active = false; @@ -78,7 +81,7 @@ namespace butl template <typename P> inline auto_rm<P>& auto_rm<P>:: - operator= (auto_rm&& x) + operator= (auto_rm&& x) noexcept { if (this != &x) { @@ -134,54 +137,28 @@ namespace butl static_cast<std::uint16_t> (y)); } - // path_match_flags - // - inline path_match_flags operator& (path_match_flags x, path_match_flags y) - { - return x &= y; - } - - inline path_match_flags operator| (path_match_flags x, path_match_flags y) - { - return x |= y; - } - - inline path_match_flags operator&= (path_match_flags& x, path_match_flags y) - { - return x = static_cast<path_match_flags> ( - static_cast<std::uint16_t> (x) & - static_cast<std::uint16_t> (y)); - } - - inline path_match_flags operator|= (path_match_flags& x, path_match_flags y) - { - return x = static_cast<path_match_flags> ( - static_cast<std::uint16_t> (x) | - static_cast<std::uint16_t> (y)); - } - // dir_entry // inline entry_type dir_entry:: ltype () const { - return t_ != entry_type::unknown ? t_ : (t_ = type (false)); + return t_ ? *t_ : *(t_ = type (false /* follow_symlinks */)); } inline entry_type dir_entry:: type () const { entry_type t (ltype ()); - return t != entry_type::symlink - ? t - : lt_ != entry_type::unknown ? lt_ : (lt_ = type (true)); + return t != entry_type::symlink ? t : + lt_ ? *lt_ : + *(lt_ = type (true /* follow_symlinks */)); } // dir_iterator // inline dir_iterator:: dir_iterator (dir_iterator&& x) noexcept - : e_ (std::move (x.e_)), h_ (x.h_), ignore_dangling_ (x.ignore_dangling_) + : e_ (std::move (x.e_)), h_ (x.h_), mode_ (x.mode_) { #ifndef _WIN32 x.h_ = nullptr; |