summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/util.c b/util.c
index ddc919584c..9c22285a18 100644
--- a/util.c
+++ b/util.c
@@ -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;
+}