ref: 6b823d1993cb4bf0b01fca63cb926f8979580ce2
parent: 580c8e89e13fedf29bb809d749ba47a69e5fe68c
author: Ori Bernstein <[email protected]>
date: Thu Sep 4 14:43:40 EDT 2014
Split blat() and add an 'fblat()' version.
--- a/libstd/blat.myr
+++ b/libstd/blat.myr
@@ -3,17 +3,22 @@
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