# HG changeset patch # User Rob Landley # Date 1338576641 18000 # Node ID 1dcd7994abeaddd2c6fd2b5bc7347f0040c12a4c # Parent ca6875170b9a19d7f293ea6589ebdec21fe7e866 Add xrealpath() at suggestion of Ashish Briggers. diff -r ca6875170b9a -r 1dcd7994abea lib/lib.c --- a/lib/lib.c Thu May 31 21:22:10 2012 -0500 +++ b/lib/lib.c Fri Jun 01 13:50:41 2012 -0500 @@ -345,6 +345,14 @@ 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); diff -r ca6875170b9a -r 1dcd7994abea lib/lib.h --- a/lib/lib.h Thu May 31 21:22:10 2012 -0500 +++ b/lib/lib.h Fri Jun 01 13:50:41 2012 -0500 @@ -116,6 +116,7 @@ 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);