diff options
author | Tharre <tharre3@gmail.com> | 2017-01-31 23:48:53 +0100 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2017-01-31 23:53:41 +0100 |
commit | 921268159d96efeb136fcfd29e8ba3212fd0a507 (patch) | |
tree | 0a557a29ce38a61efffd4d89278f28b397d5398b /src/filepath.c | |
parent | a1b25d96c528370c71c64a0e13570be435dcd0f9 (diff) | |
download | redo-921268159d96efeb136fcfd29e8ba3212fd0a507.tar.gz redo-921268159d96efeb136fcfd29e8ba3212fd0a507.tar.xz redo-921268159d96efeb136fcfd29e8ba3212fd0a507.zip |
Add make_abs() utility function
Diffstat (limited to 'src/filepath.c')
-rw-r--r-- | src/filepath.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/filepath.c b/src/filepath.c index 2186881..b752e08 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -1,6 +1,6 @@ /* filepath.c * - * Copyright (c) 2014 Tharre + * Copyright (c) 2014-2017 Tharre * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -125,3 +125,11 @@ void mkpath(char *path, mode_t mode) { *p = '/'; } } + +/* Make path absolute by prepending root, if path isn't already absolute. */ +char *make_abs(char *root, char *path) { + if (!is_absolute(path)) + return concat(3, root, "/", path); + else + return xstrdup(path); +} |