platform_unix.c
changeset 90 1b004ccf775b
parent 89 0befb9dfdee4
child 91 6db187bc77c7
--- a/platform_unix.c	Wed May 18 18:20:06 2005 +0000
+++ b/platform_unix.c	Wed May 18 18:23:13 2005 +0000
@@ -524,7 +524,21 @@
 
 char *get_current_dir(char *buf, size_t bufsize)
 {
-    return(getcwd(buf, bufsize));
+    size_t buflen = 0;
+    if (getcwd(buf, bufsize) == NULL)
+        return(NULL);
+
+    buflen = strlen(buf) + 1;
+    if (buflen <= bufsize)
+    {
+        *buf = '\0';
+        return(NULL);
+    } /* if */
+
+    if (buf[buflen - 2] != '/')
+        strcat(buf, "/");
+
+    return(buf);
 } /* get_current_dir */