X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=libatalk%2Futil%2Funix.c;h=d202b99a31f9d1dc165c7836b8b43d3d0fcd6f4c;hp=c16c5da5b50d1514243a29c0afb3edd9bd7593f6;hb=2fdd522410f80afcd055d7333f491ee6c0b4b9fa;hpb=3e5cb6c7f7ee853300e3486c20890813c6182d3f diff --git a/libatalk/util/unix.c b/libatalk/util/unix.c index c16c5da5..d202b99a 100644 --- a/libatalk/util/unix.c +++ b/libatalk/util/unix.c @@ -40,6 +40,7 @@ #include #include #include +#include /* close all FDs >= a specified value */ static void closeall(int fd) @@ -110,6 +111,31 @@ const char *getcwdpath(void) return strerror(errno); } +/*! + * Make argument path absoulte + * + * @returns pointer to path or pointer to error messages on error + */ +const char *abspath(const char *name) +{ + static char buf[MAXPATHLEN + 1]; + char *p; + int n; + + if (name[0] == '/') + return name; + + if ((p = getcwd(buf, MAXPATHLEN)) == NULL) + return strerror(errno); + + n = strlen(buf); + if (buf[n-1] != '/') + buf[n++] = '/'; + + strlcpy(buf + n, name, MAXPATHLEN - n); + return buf; +} + /*! * Takes a buffer with a path, strips slashs, returns basename *