aboutsummaryrefslogtreecommitdiff
path: root/libbutl/filesystem.mxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-04-28 17:58:36 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2018-04-28 17:35:54 +0200
commit085493111005770ed33beeba07d317b6eba0c851 (patch)
tree669bfadb85390728e93338a8a352e2f1dedae11e /libbutl/filesystem.mxx
parenteba3042910f063ae638a7e0134b79175978e2fca (diff)
Add support for directory symlinks on Windows
Diffstat (limited to 'libbutl/filesystem.mxx')
-rw-r--r--libbutl/filesystem.mxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/libbutl/filesystem.mxx b/libbutl/filesystem.mxx
index 7f93739..8d99fdc 100644
--- a/libbutl/filesystem.mxx
+++ b/libbutl/filesystem.mxx
@@ -236,7 +236,21 @@ LIBBUTL_MODEXPORT namespace butl
// 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.
+ // Note that on Windows file symlinks are currently not supported. Directory
+ // symlinks are supported via the junction mechanism that doesn't require
+ // a process to have administrative privileges. This choice, however,
+ // introduces the following restrictions:
+ //
+ // - The relative target path is completed against the current directory.
+ //
+ // - The target directory must exist. If it doesn't exists at the moment of
+ // a symlink creation, then mksymlink() call will fail. If the target is
+ // deleted at a later stage, then the filesystem API functions may fail
+ // when encounter such a symlink. This includes rmsymlink().
+ //
+ // - Symlinks are not visible when iterating over a directory with
+ // dir_iterator. As a result, a directory that contains symlinks can not
+ // be recursively deleted.
//
LIBBUTL_SYMEXPORT void
mksymlink (const path& target, const path& link, bool dir = false);
@@ -250,12 +264,26 @@ LIBBUTL_MODEXPORT namespace butl
mksymlink (target, link, true);
}
+ // Remove a symbolic link to a file (default) or directory (third argument
+ // is true). Throw std::system_error on failures.
+ //
+ LIBBUTL_SYMEXPORT rmfile_status
+ rmsymlink (const path&, bool dir = false);
+
+ // Remove a symbolic link to a directory. Throw std::system_error on
+ // failures.
+ //
+ inline rmfile_status
+ rmsymlink (const dir_path& link)
+ {
+ return rmsymlink (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.
+ // Note that on Linix, FreeBSD, Windows and some other platforms the target
+ // can not be a directory.
//
LIBBUTL_SYMEXPORT void
mkhardlink (const path& target, const path& link, bool dir = false);