diff options
| author | Emil Williams | 2026-02-20 06:18:48 +0000 |
|---|---|---|
| committer | Emil Williams | 2026-02-20 06:18:48 +0000 |
| commit | 88e12f4a22111903fc23488898f073502639635c (patch) | |
| tree | 87963ce958b8a48be77bf9895f7527f532008dab /chad/experimental/root.c | |
| parent | d352d3cf415083fd0f07321273d1d03b26a323e0 (diff) | |
| download | libchad-88e12f4a22111903fc23488898f073502639635c.tar.xz libchad-88e12f4a22111903fc23488898f073502639635c.tar.zst | |
Make experimental and librarize
Diffstat (limited to 'chad/experimental/root.c')
| -rw-r--r-- | chad/experimental/root.c | 13 |
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); + } +} |
