Minor get_current_dir() fixes.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 18 May 2005 18:23:13 +0000
changeset 90 1b004ccf775b
parent 89 0befb9dfdee4
child 91 6db187bc77c7
Minor get_current_dir() fixes.
platform_unix.c
platform_win32.c
--- 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 */
 
 
--- a/platform_win32.c	Wed May 18 18:20:06 2005 +0000
+++ b/platform_win32.c	Wed May 18 18:23:13 2005 +0000
@@ -128,7 +128,7 @@
     if (buflen <= bufsize)
     {
         *buf = '\0';
-        return NULL;
+        return(NULL);
     } /* if */
 
     if (buf[buflen - 2] != '\\')