Skip to content

Commit e3e46cd

Browse files
mhaggerpeff
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent d6052ab commit e3e46cd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

abspath.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ const char *real_path(const char *path)
153153
return real_path_internal(path, 1);
154154
}
155155

156+
const char *real_path_if_valid(const char *path)
157+
{
158+
return real_path_internal(path, 0);
159+
}
160+
156161
static const char *get_pwd_cwd(void)
157162
{
158163
static char cwd[PATH_MAX + 1];

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ static inline int is_absolute_path(const char *path)
714714
}
715715
int is_directory(const char *);
716716
const char *real_path(const char *path);
717+
const char *real_path_if_valid(const char *path);
717718
const char *absolute_path(const char *path);
718719
const char *relative_path(const char *abs, const char *base);
719720
int normalize_path_copy(char *dst, const char *src);

0 commit comments

Comments
 (0)