aboutsummaryrefslogtreecommitdiff
path: root/butl/filesystem
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-02-10 16:10:33 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-02-13 12:55:34 +0300
commit31e91691e815074ebdb49d258967e2b2a0bfc965 (patch)
tree1739e815c312b40fa9a8c64b7b144cf60d4c28bb /butl/filesystem
parent66ca47f856cc04774cbe07dc67e2e099e5d527f3 (diff)
Add path_entry(), fixes for path
Diffstat (limited to 'butl/filesystem')
-rw-r--r--butl/filesystem37
1 files changed, 25 insertions, 12 deletions
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 <cstddef> // ptrdiff_t
-#include <cstdint> // uint16_t
-#include <utility> // move()
+#include <cstddef> // ptrdiff_t
+#include <cstdint> // uint16_t
+#include <utility> // move(), pair
#include <iterator>
#include <butl/export>
@@ -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<bool, entry_type>
+ path_entry (const char*, bool follow_symlinks = false);
+
+ inline std::pair<bool, entry_type>
+ 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: