aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/vlib/os2/os2_darwin.c.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/old/vlib/os2/os2_darwin.c.v
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/old/vlib/os2/os2_darwin.c.v')
-rw-r--r--v_windows/v/old/vlib/os2/os2_darwin.c.v36
1 files changed, 36 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/os2/os2_darwin.c.v b/v_windows/v/old/vlib/os2/os2_darwin.c.v
new file mode 100644
index 0000000..b04ee11
--- /dev/null
+++ b/v_windows/v/old/vlib/os2/os2_darwin.c.v
@@ -0,0 +1,36 @@
+module os2
+
+#include <fcntl.h>
+
+struct File {
+ fd int
+}
+
+fn C.perror(&char)
+
+fn C.open(&byte, int, int) int
+
+fn C.write(voidptr, &byte, int) int
+
+fn C.close(int) int
+
+pub fn create(path string) ?File {
+ fd := C.open(path.str, C.O_CREAT | C.O_TRUNC | C.O_WRONLY, o644) // 511
+ if fd == -1 {
+ return error('failed to create "$path":')
+ // os.print_c_errno()
+ }
+ return File{fd}
+}
+
+pub fn (f File) writeln(s string) {
+ ss := s + '\n'
+ ret := C.write(f.fd, ss.str, s.len + 1)
+ if ret == -1 {
+ C.perror('failed to write')
+ }
+}
+
+pub fn (f File) close() {
+ C.close(f.fd)
+}