changeset 585:1dcd7994abea

Add xrealpath() at suggestion of Ashish Briggers.
author Rob Landley <rob@landley.net>
date Fri, 01 Jun 2012 13:50:41 -0500
parents ca6875170b9a
children 0353ed084559
files lib/lib.c lib/lib.h
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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);