From 31e91691e815074ebdb49d258967e2b2a0bfc965 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 10 Feb 2017 16:10:33 +0300 Subject: Add path_entry(), fixes for path --- butl/filesystem | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'butl/filesystem') diff --git a/butl/filesystem b/butl/filesystem index c030ecd..ef715c6 100644 --- a/butl/filesystem +++ b/butl/filesystem @@ -20,9 +20,9 @@ typedef int mode_t; #endif -#include // ptrdiff_t -#include // uint16_t -#include // move() +#include // ptrdiff_t +#include // uint16_t +#include // move(), pair #include #include @@ -61,6 +61,28 @@ namespace butl entry_exists (const path& p, bool fs = false) { return entry_exists (p.string ().c_str (), fs);} + // Filesystem entry type. + // + enum class entry_type + { + unknown, + regular, + directory, + symlink, + other + }; + + // Return a flag indicating if the path is to an existing file system entry + // and its type if so. Note that by default this function doesn't follow + // symlinks. + // + LIBBUTL_EXPORT std::pair + path_entry (const char*, bool follow_symlinks = false); + + inline std::pair + path_entry (const path& p, bool fs = false) { + return path_entry (p.string ().c_str (), fs);} + // Return true if the directory is empty. Note that the path must exist // and be a directory. // @@ -279,15 +301,6 @@ namespace butl // Directory entry iteration. // - enum class entry_type - { - unknown, - regular, - directory, - symlink, - other - }; - class LIBBUTL_EXPORT dir_entry { public: -- cgit v1.1