From 1e2e28d3e442ba3c95a5c2b9e5d920c72f6cee43 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Aug 2019 13:11:55 +0200 Subject: Add mkanylink() filesystem function --- libbutl/filesystem.mxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'libbutl/filesystem.mxx') diff --git a/libbutl/filesystem.mxx b/libbutl/filesystem.mxx index 2e3a0d9..e028975 100644 --- a/libbutl/filesystem.mxx +++ b/libbutl/filesystem.mxx @@ -289,8 +289,8 @@ LIBBUTL_MODEXPORT namespace butl // 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, Windows and some other platforms the target - // can not be a directory. + // Note that on Linux, FreeBSD, Windows and some other platforms the target + // cannot be a directory. // LIBBUTL_SYMEXPORT void mkhardlink (const path& target, const path& link, bool dir = false); @@ -303,6 +303,23 @@ LIBBUTL_MODEXPORT namespace butl mkhardlink (target, link, true /* dir */); } + // Make a symlink, hardlink, or, if `copy` is true, a copy of a file (note: + // no directories, only files), whichever is possible in that order. If + // `relative` is true, then make the symlink target relative to the link + // directory (note: it is the caller's responsibility to make sure this is + // possible). + // + // On success, return the type of entry created: `regular` for copy, + // `symlink` for symlink, and `other` for hardlink. On failure, throw a + // `pair` with the first half indicating the part + // of the logic that caused the error. + // + LIBBUTL_SYMEXPORT entry_type + mkanylink (const path& target, + const path& link, + bool copy, + bool relative = false); + // File copy flags. // enum class cpflags: std::uint16_t -- cgit v1.1