diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 7664df59d0..2bc90da3d2 100644 --- a/src/util.c +++ b/src/util.c @@ -582,6 +582,26 @@ int readlink_malloc(const char *p, char **r) { } } +int readlink_and_make_absolute(const char *p, char **r) { + char *target, *k; + int j; + + assert(p); + assert(r); + + if ((j = readlink_malloc(p, &target)) < 0) + return j; + + k = file_in_same_dir(p, target); + free(target); + + if (!k) + return -ENOMEM; + + *r = k; + return 0; +} + char *file_name_from_path(const char *p) { char *r; |