added currentDirectory()
authorewt <devnull@localhost>
Fri, 8 Jan 1999 03:10:12 +0000 (03:10 +0000)
committerewt <devnull@localhost>
Fri, 8 Jan 1999 03:10:12 +0000 (03:10 +0000)
CVS patchset: 2678
CVS date: 1999/01/08 03:10:12

lib/misc.c
lib/misc.h

index 51da617..6c2d1d7 100644 (file)
@@ -364,3 +364,17 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) {
 
     return 0;
 }
+
+char * currentDirectory(void) {
+    int currDirLen;
+    char * currDir;
+
+    currDirLen = 50;
+    currDir = malloc(currDirLen);
+    while (!getcwd(currDir, currDirLen) && errno == ERANGE) {
+       currDirLen += 50;
+       currDir = realloc(currDir, currDirLen);
+    }
+
+    return currDir;
+}
index 44d9978..d26a946 100644 (file)
@@ -27,5 +27,6 @@ char * uidToUname(uid_t uid);
 char * gidToGname(gid_t gid);
 
 int makeTempFile(const char * prefix, /*@out@*/const char ** fnptr, /*@out@*/FD_t * fdptr);
+char * currentDirectory(void);         /* result needs to be freed */
 
 #endif /* H_MISC */