platform/unix.c
changeset 100 d2f04ab4b412
parent 79 5dbb03944ef0
child 115 c0671785777b
--- a/platform/unix.c	Fri Sep 14 22:58:04 2001 +0000
+++ b/platform/unix.c	Fri Sep 14 22:59:53 2001 +0000
@@ -436,11 +436,18 @@
                 free(retval);
             BAIL_IF_MACRO(1, ERR_OUT_OF_MEMORY, NULL);
         } /* if */
-
+	
         retval = ptr;
         ptr = getcwd(retval, allocSize);
-    } while (ptr == NULL);
-
+    } while (ptr == NULL && errno == ERANGE);
+    if(ptr == NULL && errno) {
+	/* getcwd() failed for some reason, for example current
+	 * directory not existing.
+	 */
+	if (retval != NULL)
+	    free(retval);
+	BAIL_IF_MACRO(1, ERR_NO_SUCH_FILE, NULL);
+    }
     return(retval);
 } /* __PHYSFS_platformCurrentDir */