diff options
Diffstat (limited to 'lib/misc.c')
-rw-r--r-- | lib/misc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/misc.c b/lib/misc.c index 51da6178d..6c2d1d758 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -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; +} |