diff options
-rw-r--r-- | lib/lib.c | 8 | ||||
-rw-r--r-- | lib/lib.h | 1 |
2 files changed, 9 insertions, 0 deletions
@@ -345,6 +345,14 @@ char *xabspath(char *path) return path; } +// Resolve all symlinks, returning malloc() memory. +char *xrealpath(char *path) +{ + char *new = realpath(path, NULL); + if (!new) perror_exit("realpath '%s'", path); + return new; +} + void xchdir(char *path) { if (chdir(path)) error_exit("chdir '%s'", path); @@ -116,6 +116,7 @@ char *xreadfile(char *name); char *xgetcwd(void); void xstat(char *path, struct stat *st); char *xabspath(char *path); +char *xrealpath(char *path); void xchdir(char *path); void xmkpath(char *path, int mode); void xsetuid(uid_t uid); |