Skip to content
Browse files

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>
  • Loading branch information...
1 parent d6052ab commit e3e46cdbd45c2e7383df9de1787e23489dc66dbc @mhagger mhagger committed with peff Oct 28, 2012
Showing with 6 additions and 0 deletions.
  1. +5 −0 abspath.c
  2. +1 −0 cache.h
View
5 abspath.c
@@ -153,6 +153,11 @@ const char *real_path(const char *path)
return real_path_internal(path, 1);
}
+const char *real_path_if_valid(const char *path)
+{
+ return real_path_internal(path, 0);
+}
+
static const char *get_pwd_cwd(void)
{
static char cwd[PATH_MAX + 1];
View
1 cache.h
@@ -714,6 +714,7 @@ static inline int is_absolute_path(const char *path)
}
int is_directory(const char *);
const char *real_path(const char *path);
+const char *real_path_if_valid(const char *path);
const char *absolute_path(const char *path);
const char *relative_path(const char *abs, const char *base);
int normalize_path_copy(char *dst, const char *src);

0 comments on commit e3e46cd

Please sign in to comment.
Something went wrong with that request. Please try again.