shithub: mc

Download patch

ref: 490aee2305257ae7a9f049e1a2ef1a00e0cc7116
parent: c4704d52dbfc97af7c1fe1d7ea73fae99d1bd976
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