diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -11,6 +11,7 @@ **********************************************************************/ #include <stdio.h> +#include <errno.h> #ifdef NT #include "missing/file.h" @@ -628,3 +629,17 @@ ruby_strdup(str) return tmp; } + +char * +ruby_getcwd() +{ + int size = 200; + char *buf = xmalloc(size); + + while (!getcwd(buf, size)) { + if (errno != ERANGE) rb_sys_fail(buf); + size *= 2; + buf = xrealloc(buf, size); + } + return buf; +} |