aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/file-system.hh
diff options
context:
space:
mode:
authorRebecca Turner <rbt@sent.as>2024-08-25 11:58:55 -0700
committerRebecca Turner <rbt@sent.as>2024-08-25 15:54:22 -0700
commit690f07272e58bfe86d12adb0bd6c81c031f930fd (patch)
treee01efa0e48d38eb44eb1d3445719a6adab29a33a /src/libutil/file-system.hh
parent5fc6fcb31035f79a8e590f07d73dc6cc592e9e29 (diff)
Support relative and `~/` paths in config settings
Change-Id: I5566a9858ba255f4ac5051d1368c7dfb24460f0a
Diffstat (limited to 'src/libutil/file-system.hh')
-rw-r--r--src/libutil/file-system.hh10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/file-system.hh b/src/libutil/file-system.hh
index e49323e84..0a54d1a3b 100644
--- a/src/libutil/file-system.hh
+++ b/src/libutil/file-system.hh
@@ -63,6 +63,16 @@ Path canonPath(PathView path, bool resolveSymlinks = false);
Path realPath(Path const & path);
/**
+ * Resolve a tilde path like `~/puppy.nix` into an absolute path.
+ *
+ * If `home` is given, it's substituted for `~/` at the start of the input
+ * `path`. Otherwise, an error is thrown.
+ *
+ * If the path starts with `~` but not `~/`, an error is thrown.
+ */
+Path tildePath(Path const & path, const std::optional<Path> & home = std::nullopt);
+
+/**
* Change the permissions of a path
* Not called `chmod` as it shadows and could be confused with
* `int chmod(char *, mode_t)`, which does not handle errors