core: Add getcwd.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Nov 2018 09:16:19 +0000 (10:16 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Nov 2018 09:16:19 +0000 (10:16 +0100)
* src/posix.c (getcwd_): New function.

src/posix.c

index d8deb3a93fe52217849324b1fbe79bba8fc2d552..efef1ca748c33966a9cf2ffeb152a3a3dea24d16 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <fcntl.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -371,3 +372,11 @@ get_internal_run_time ()
                                                ts.tv_nsec - g_start_time.tv_nsec);
   return MAKE_NUMBER (time);
 }
+
+SCM
+getcwd_ () ///((name . "getcwd"))
+{
+  char buf[PATH_MAX];
+  return MAKE_STRING (cstring_to_list (getcwd (buf, PATH_MAX)));
+}
+