diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-10-10 18:04:09 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-10-10 18:04:09 +0200 |
commit | 236f43bec5d539cc55b7dc8ba92854a22b454495 (patch) | |
tree | e4a6e99ab3c4c621c0e1d9b0714ce8a0c53e77ff /include | |
parent | add strstarts strends strcasestarts strcaseends wcsstarts wcsends wcscasestarts wcscaseends (diff) | |
download | slibc-236f43bec5d539cc55b7dc8ba92854a22b454495.tar.gz slibc-236f43bec5d539cc55b7dc8ba92854a22b454495.tar.bz2 slibc-236f43bec5d539cc55b7dc8ba92854a22b454495.tar.xz |
add abspath and relpath
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | include/stdlib.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/stdlib.h b/include/stdlib.h index 89712f9..eca92b2 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -93,6 +93,46 @@ lldiv_t lldiv(long long, long long) __GCC_ONLY(__attribute__((const))); +#if !defined(__PORTABLE) +/** + * Get the absolute path of a file. + * It will remove all redundant slashes, all "./":s, + * and all "../":s, but not resolve symbolic links. + * + * This is a slibc extension. + * + * @param file The file. + * @param ref The directory the file's specified path is + * relative, `NULL` for the current working directory. + * @return The file's absolute pathname. Will end with a slash + * if `file` does. (Or if `ref` does but file is empty.) + * + * @throws ENOMEM The process cannot allocate more memory. + */ +char* abspath(const char*, const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull(1), malloc))); + +/** + * Get the relative path of a file. + * + * This is a slibc extension. + * + * @param file The file. + * @param ref The file the result shall be relative to, + * `NULL` for the current working directory. + * If and only if this path ends with a slash, + * (or if it is `NULL`,) it will be treated as + * a directory in which a symbolic link, with + * the result as it target, can be located to + * point to `file`. + * + * @throws ENOMEM The process cannot allocate more memory. + */ +char* relpath(const char*, const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull(1), malloc))); +#endif + + /* TODO implement rand-functions */ #define RAND_MAX 1 |