summaryrefslogtreecommitdiff
path: root/libstd/blat.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-09-04 18:43:40 -0400
committerOri Bernstein <ori@eigenstate.org>2014-09-04 18:43:40 -0400
commit6b823d1993cb4bf0b01fca63cb926f8979580ce2 (patch)
treee0231e9a8b5a7cf5fc92edda5e165bd321b9967f /libstd/blat.myr
parent580c8e89e13fedf29bb809d749ba47a69e5fe68c (diff)
downloadmc-6b823d1993cb4bf0b01fca63cb926f8979580ce2.tar.gz
Split blat() and add an 'fblat()' version.
Diffstat (limited to 'libstd/blat.myr')
-rw-r--r--libstd/blat.myr11
1 files changed, 8 insertions, 3 deletions
diff --git a/libstd/blat.myr b/libstd/blat.myr
index ccd5ad0..32c105d 100644
--- a/libstd/blat.myr
+++ b/libstd/blat.myr
@@ -3,17 +3,22 @@ use "fmt.use"
pkg std =
const blat : (path : byte[:], buf : byte[:] -> bool)
+ const fblat : (f : fd, buf : byte[:] -> bool)
;;
const blat = {path, buf
var fd
- var written
- var n
fd = openmode(path, Ocreat|Owronly, 0o777)
if fd < 0
- fatal(1, "Could not open file \"%s\"", path)
+ -> false
;;
+ -> fblat(fd, buf)
+}
+
+
+const fblat = {fd, buf
+ var written, n
n = 0
while true