]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/util/unix.c
Move fullpathname() around in libatalk
[netatalk.git] / libatalk / util / unix.c
index c16c5da5b50d1514243a29c0afb3edd9bd7593f6..0e466307bcd30d6ad13ec3af0c8444be0b26bd45 100644 (file)
@@ -110,6 +110,28 @@ const char *getcwdpath(void)
         return strerror(errno);
 }
 
+/*!
+ * @brief Request absolute path
+ *
+ * @returns Absolute filesystem path to object
+ */
+const char *fullpathname(const char *name)
+{
+    static char wd[MAXPATHLEN + 1];
+
+    if (name[0] == '/')
+        return name;
+
+    if (getcwd(wd , MAXPATHLEN)) {
+        strlcat(wd, "/", MAXPATHLEN);
+        strlcat(wd, name, MAXPATHLEN);
+    } else {
+        strlcpy(wd, name, MAXPATHLEN);
+    }
+
+    return wd;
+}
+
 /*!
  * Takes a buffer with a path, strips slashs, returns basename
  *