1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <limits.h> #include <stdlib.h> char *canonicalize_file_name(const char *path) { char *s = malloc(PATH_MAX); if (s == NULL) return NULL; if (realpath(path, s) == NULL) { free(s); return NULL; } return s; }