aboutsummaryrefslogtreecommitdiff
path: root/chad/experimental/root.c
diff options
context:
space:
mode:
authorEmil Williams2026-02-20 06:18:48 +0000
committerEmil Williams2026-02-20 06:18:48 +0000
commit88e12f4a22111903fc23488898f073502639635c (patch)
tree87963ce958b8a48be77bf9895f7527f532008dab /chad/experimental/root.c
parentd352d3cf415083fd0f07321273d1d03b26a323e0 (diff)
downloadlibchad-88e12f4a22111903fc23488898f073502639635c.tar.xz
libchad-88e12f4a22111903fc23488898f073502639635c.tar.zst
Make experimental and librarize
Diffstat (limited to 'chad/experimental/root.c')
-rw-r--r--chad/experimental/root.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/chad/experimental/root.c b/chad/experimental/root.c
new file mode 100644
index 0000000..f7447eb
--- /dev/null
+++ b/chad/experimental/root.c
@@ -0,0 +1,13 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <chad/experimental/root.h>
+void Root(char * filename) {
+ char path[PATH_MAX], * terminator;
+ if (!realpath(filename, path)) { return; }
+ if ((terminator = strrchr(path, '/'))) {
+ *terminator = '\0';
+ chdir(path);
+ }
+}