aboutsummaryrefslogtreecommitdiff
path: root/butl/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'butl/filesystem')
-rw-r--r--butl/filesystem50
1 files changed, 26 insertions, 24 deletions
diff --git a/butl/filesystem b/butl/filesystem
index 7b23fc5..2c4f3a4 100644
--- a/butl/filesystem
+++ b/butl/filesystem
@@ -25,6 +25,8 @@
#include <utility> // move()
#include <iterator>
+#include <butl/export>
+
#include <butl/path>
#include <butl/timestamp>
@@ -33,13 +35,13 @@ namespace butl
// Return true if the path is to an existing directory. Note that
// this function resolves symlinks.
//
- bool
+ LIBBUTL_EXPORT bool
dir_exists (const path&);
// Return true if the path is to an existing regular file. Note that
// this function resolves symlinks.
//
- bool
+ LIBBUTL_EXPORT bool
file_exists (const path&);
// Try to create a directory unless it already exists. If you expect
@@ -55,13 +57,13 @@ namespace butl
//
enum class mkdir_status {success, already_exists};
- mkdir_status
+ LIBBUTL_EXPORT mkdir_status
try_mkdir (const dir_path&, mode_t = 0777);
// The '-p' version of the above (i.e., it creates the parent
// directories if necessary).
//
- mkdir_status
+ LIBBUTL_EXPORT mkdir_status
try_mkdir_p (const dir_path&, mode_t = 0777);
// Try to remove the directory returning not_exist if it does not exist
@@ -70,20 +72,20 @@ namespace butl
//
enum class rmdir_status {success, not_exist, not_empty};
- rmdir_status
+ LIBBUTL_EXPORT rmdir_status
try_rmdir (const dir_path&, bool ignore_error = false);
// The '-r' (recursive) version of the above. Note that it will
// never return not_empty.
//
- rmdir_status
+ LIBBUTL_EXPORT rmdir_status
try_rmdir_r (const dir_path&, bool ignore_error = false);
// As above but throws rather than returns not_exist if the directory
// does not exist (unless ignore_error is true), so check before calling.
// If the second argument is false, then the directory itself is not removed.
//
- void
+ LIBBUTL_EXPORT void
rmdir_r (const dir_path&, bool dir = true, bool ignore_error = false);
// Try to remove the file (or symlinks) returning not_exist if
@@ -92,7 +94,7 @@ namespace butl
//
enum class rmfile_status {success, not_exist};
- rmfile_status
+ LIBBUTL_EXPORT rmfile_status
try_rmfile (const path&, bool ignore_error = false);
// Automatically try to remove the path on destruction unless cancelled.
@@ -132,7 +134,7 @@ namespace butl
//
// Note that Windows symlinks are currently not supported.
//
- void
+ LIBBUTL_EXPORT void
mksymlink (const path& target, const path& link, bool dir = false);
// Create a symbolic link to a directory. Throw std::system_error on
@@ -151,7 +153,7 @@ namespace butl
// be a directory. While Windows support directories (via junktions), this
// is currently not implemented.
//
- void
+ LIBBUTL_EXPORT void
mkhardlink (const path& target, const path& link, bool dir = false);
// Create a hard link to a directory. Throw std::system_error on failures.
@@ -172,10 +174,10 @@ namespace butl
none = 0
};
- cpflags operator& (cpflags, cpflags);
- cpflags operator| (cpflags, cpflags);
- cpflags operator&= (cpflags&, cpflags);
- cpflags operator|= (cpflags&, cpflags);
+ inline cpflags operator& (cpflags, cpflags);
+ inline cpflags operator| (cpflags, cpflags);
+ inline cpflags operator&= (cpflags&, cpflags);
+ inline cpflags operator|= (cpflags&, cpflags);
// Copy a regular file, including its permissions. Throw std::system_error
// on failure. Fail if the destination file exists and the overwrite_content
@@ -192,7 +194,7 @@ namespace butl
// destination is a dangling symbolic link, then this function will still
// fail.
//
- void
+ LIBBUTL_EXPORT void
cpfile (const path& from, const path& to, cpflags = cpflags::none);
// Copy a regular file to an existing directory.
@@ -208,7 +210,7 @@ namespace butl
// by throwing std::system_error. Note that this function resolves
// symlinks.
//
- timestamp
+ LIBBUTL_EXPORT timestamp
file_mtime (const path&);
// Path permissions.
@@ -232,21 +234,21 @@ namespace butl
none = 0
};
- permissions operator& (permissions, permissions);
- permissions operator| (permissions, permissions);
- permissions operator&= (permissions&, permissions);
- permissions operator|= (permissions&, permissions);
+ inline permissions operator& (permissions, permissions);
+ inline permissions operator| (permissions, permissions);
+ inline permissions operator&= (permissions&, permissions);
+ inline permissions operator|= (permissions&, permissions);
// Get path permissions. Throw std::system_error on failure. Note that this
// function resolves symlinks.
//
- permissions
+ LIBBUTL_EXPORT permissions
path_permissions (const path&);
// Set path permissions. Throw std::system_error on failure. Note that this
// function resolves symlinks.
//
- void
+ LIBBUTL_EXPORT void
path_permissions (const path&, permissions);
// Directory entry iteration.
@@ -260,7 +262,7 @@ namespace butl
other
};
- class dir_entry
+ class LIBBUTL_EXPORT dir_entry
{
public:
typedef butl::path path_type;
@@ -299,7 +301,7 @@ namespace butl
dir_path b_;
};
- class dir_iterator
+ class LIBBUTL_EXPORT dir_iterator
{
public:
typedef dir_entry value_type;