aboutsummaryrefslogtreecommitdiff
path: root/butl/filesystem
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-06-22 23:00:36 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-06-23 15:13:25 +0300
commite0b126d8c7f691856ec4d80bb57cb1ba5c71fd69 (patch)
tree20613b639d81a08dd1189ef4db37f41f3de54a68 /butl/filesystem
parent748eab79085d7c8a3b3da90316a90a892db884ae (diff)
Add mkslink(), mkhlink()
Diffstat (limited to 'butl/filesystem')
-rw-r--r--butl/filesystem35
1 files changed, 35 insertions, 0 deletions
diff --git a/butl/filesystem b/butl/filesystem
index ab39f36..565f465 100644
--- a/butl/filesystem
+++ b/butl/filesystem
@@ -120,6 +120,41 @@ namespace butl
using auto_rmfile = auto_rm<path>;
using auto_rmdir = auto_rm<dir_path>; // Note: recursive (rm_r).
+ // Create a symbolic link to a file (default) or directory (third argument
+ // is true). Throw std::system_error on failures.
+ //
+ // Note that Windows symlinks are currently not supported.
+ //
+ void
+ mksymlink (const path& target, const path& link, bool dir = false);
+
+ // Create a symbolic link to a directory. Throw std::system_error on
+ // failures.
+ //
+ inline void
+ mksymlink (const dir_path& target, const dir_path& link)
+ {
+ mksymlink (target, link, true);
+ }
+
+ // Create a hard link to a file (default) or directory (third argument is
+ // true). Throw std::system_error on failures.
+ //
+ // Note that on Linix, FreeBSD and some other platforms the target can not
+ // be a directory. While Windows support directories (via junktions), this
+ // is currently not implemented.
+ //
+ void
+ mkhardlink (const path& target, const path& link, bool dir = false);
+
+ // Create a hard link to a directory. Throw std::system_error on failures.
+ //
+ inline void
+ mkhardlink (const dir_path& target, const dir_path& link)
+ {
+ mkhardlink (target, link, true);
+ }
+
// Return timestamp_nonexistent if the entry at the specified path
// does not exist or is not a path. All other errors are reported
// by throwing std::system_error. Note that this function resolves