Introduce new function real_path_if_valid()
The function is like real_path(), except that it returns NULL on error instead of dying. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jeff King <peff@peff.net>
Michael Haggerty committed
Oct 28, 2012 at 17:16 UTC
e3e46cdbd45c2e7383df9de1787e23489dc66dbc
2 files changed
+6
abspath.c
+5
@@ -153,6 +153,11 @@ const char *real_path(const char *path)
153
return real_path_internal(path, 1);
154
}
155
156
+const char *real_path_if_valid(const char *path)
157
+{
158
+ return real_path_internal(path, 0);
159
+}
160
+
161
static const char *get_pwd_cwd(void)
162
{
163
static char cwd[PATH_MAX + 1];
cache.h
+1
@@ -714,6 +714,7 @@ static inline int is_absolute_path(const char *path)
714
}
715
int is_directory(const char *);
716
const char *real_path(const char *path);
717
+const char *real_path_if_valid(const char *path);
718
const char *absolute_path(const char *path);
719
const char *relative_path(const char *abs, const char *base);
720
int normalize_path_copy(char *dst, const char *src);