diff options
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); + } +} |
