ref: 0e2a8ea63cfc8b070335288ce97c87e4a7fa2548
parent: d2f0c0cc30a102c6b9cdd7e4c0da840fb830e66d
author: Ori Bernstein <[email protected]>
date: Thu Jun 5 18:00:16 EDT 2014
Split open and openmode Most open calls don't need the mode param. If you need it, use openmode.
--- a/libstd/blat.myr
+++ b/libstd/blat.myr
@@ -10,7 +10,7 @@
var written
var n
- fd = open(path, Ocreat|Owronly, 0o777)
+ fd = openmode(path, Ocreat|Owronly, 0o777)
if fd < 0
fatal(1, "Could not open file \"%s\"", path)
;;
--- a/libstd/slurp.myr
+++ b/libstd/slurp.myr
@@ -18,7 +18,7 @@
var len
var buf
- fd = open(path, Ordonly, 0o777)
+ fd = open(path, Ordonly)
if fd < 0
-> `Fail "Could not open file"
;;
--- a/libstd/sys-linux.myr
+++ b/libstd/sys-linux.myr
@@ -466,7 +466,8 @@
/* fd manipulation */
- const open : (path:byte[:], opts:fdopt, mode:int64 -> fd)
+ const open : (path:byte[:], opts:fdopt -> fd)
+ const openmode : (path:byte[:], opts:fdopt, mode:int64 -> fd)
const close : (fd:fd -> int64)
const creat : (path:byte[:], mode:int64 -> fd)
const read : (fd:fd, buf:byte[:] -> size)
@@ -556,7 +557,8 @@
}
/* fd manipulation */
-const open = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
+const open = {path, opts; -> syscall(Sysopen, cstring(path), 0o644, mode) castto(fd)}
+const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
const close = {fd; -> syscall(Sysclose, fd)}
const creat = {path, mode; -> syscall(Syscreat, cstring(path), mode) castto(fd)}
const read = {fd, buf; -> syscall(Sysread, fd, buf castto(byte#), buf.len castto(size)) castto(size)}
--- a/libstd/sys-osx.myr
+++ b/libstd/sys-osx.myr
@@ -500,7 +500,8 @@
const execve : (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
/* fd manipulation */
- const open : (path:byte[:], opts:fdopt, mode:int64 -> fd)
+ const open : (path:byte[:], opts:fdopt -> fd)
+ const openmode : (path:byte[:], opts:fdopt, mode:int64 -> fd)
const close : (fd:fd -> int64)
const creat : (path:byte[:], mode:int64 -> fd)
const read : (fd:fd, buf:byte[:] -> size)
@@ -592,9 +593,10 @@
/* fd manipulation */
-const open = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
+const open = {path, opts; -> syscall(Sysopen, cstring(path), opts, 0o644) castto(fd)}
+const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
const close = {fd; -> syscall(Sysclose, fd)}
-const creat = {path, mode; -> open(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
+const creat = {path, mode; -> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
const read = {fd, buf; -> syscall(Sysread, fd, buf castto(char#), buf.len castto(size)) castto(size)}
const write = {fd, buf; -> syscall(Syswrite, fd, buf castto(char#), buf.len castto(size)) castto(size)}
const lseek = {fd, off, whence; -> syscall(Syslseek, fd, off, whence)}