aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-07-18 07:20:02 +0200
committerSven Gothel <[email protected]>2022-07-18 07:20:02 +0200
commitc7418375e65c1d4b04d59f6d935f219ea379708f (patch)
treecbd10ae1a39087e9c02adf56e9d2af899c680176 /include
parent3f9035027eb7b084dd5fcf9a732a6f0ddc4d6bcd (diff)
Add jau::fs::rename() (C++) / FileUtil.rename() (Java)
Diffstat (limited to 'include')
-rw-r--r--include/jau/file_util.hpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/jau/file_util.hpp b/include/jau/file_util.hpp
index f9da46a..47d7bc5 100644
--- a/include/jau/file_util.hpp
+++ b/include/jau/file_util.hpp
@@ -977,6 +977,24 @@ namespace jau {
*/
bool copy(const std::string& source_path, const std::string& dest_path, const copy_options copts = copy_options::none) noexcept;
+ /**
+ * Rename oldpath to newpath using POSIX `::rename()`, with the following combinations
+ * - oldpath and newpath refer to the same file, a successful no-operation.
+ * - oldpath file
+ * - newpath not-existing file
+ * - newpath existing file to be atomically replaced
+ * - oldpath directory
+ * - newpath not-existing directory
+ * - newpath existing empty directory
+ * - oldpath symlink will be renamed
+ * - newpath symlink will be overwritten
+ *
+ * @param oldpath previous path
+ * @param newpath new path
+ * @return true only if the rename operation was successful, otherwise false
+ */
+ bool rename(const std::string& oldpath, const std::string& newpath) noexcept;
+
struct mount_ctx {
bool mounted;
std::string mount_point;