summaryrefslogtreecommitdiff
path: root/lib/std/syswrap-ss+osx.myr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/syswrap-ss+osx.myr')
-rw-r--r--lib/std/syswrap-ss+osx.myr35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/std/syswrap-ss+osx.myr b/lib/std/syswrap-ss+osx.myr
new file mode 100644
index 0000000..5e7f001
--- /dev/null
+++ b/lib/std/syswrap-ss+osx.myr
@@ -0,0 +1,35 @@
+use sys
+use "errno.use"
+use "cstrconv.use"
+use "slcp.use"
+use "die.use"
+
+pkg std =
+ const exit : (status:int -> void)
+ pkglocal const bgetcwd : (buf : byte[:] -> errno)
+;;
+
+const exit = {status; sys.exit(status)}
+const bgetcwd = {buf
+ var path : byte[sys.Maxpathlen]
+ var fd, len, err
+
+ fd = sys.open(".", sys.Ordonly)
+ if fd < 0
+ -> fd castto(errno)
+ ;;
+ /*
+ FIXME: if the path is longer than sys.Pathmax, we should fall back to
+ the ugly method of finding the path.
+ */
+ err = sys.fcntl(fd, sys.Fgetpath, path[:] castto(byte#)) castto(errno)
+ if err < 0
+ -> err
+ ;;
+ len = cstrlen(path[:])
+ if len >= buf.len
+ -> Erange
+ ;;
+ slcp(buf[:len], path[:len])
+ -> len castto(errno)
+}