aboutsummaryrefslogtreecommitdiff
path: root/chad/experimental/root.c
blob: f7447eb56e5916d8fd0c8d6b369e8ebefbf542eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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);
  }
}