summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-10-06 17:14:52 -0400
committerOri Bernstein <ori@eigenstate.org>2014-10-06 17:14:52 -0400
commiteac78a0fb1f780b2de3139fda214da9a26811fe3 (patch)
treeb79dd0167c9b4f6e4a975c76fb75e8ed5e3925fa
parent56b0a563b067269bb530d7684e01d7feef06266b (diff)
downloadlibbio-eac78a0fb1f780b2de3139fda214da9a26811fe3.tar.gz
Flush file correctly when closing.
-rw-r--r--bio.myr6
-rw-r--r--test/bio-write.myr5
2 files changed, 6 insertions, 5 deletions
diff --git a/bio.myr b/bio.myr
index d953795..d5743b5 100644
--- a/bio.myr
+++ b/bio.myr
@@ -130,11 +130,11 @@ const sysopen = {path, mode, openmode, perm
/* closes a file, flushing it to the output fd */
const close = {f
- var closed
+ var fd
- closed = (std.close(f.fd) == 0)
+ fd = f.fd
free(f)
- -> closed
+ -> std.close(fd) == 0
}
const free = {f
diff --git a/test/bio-write.myr b/test/bio-write.myr
index 6536e52..cbe7441 100644
--- a/test/bio-write.myr
+++ b/test/bio-write.myr
@@ -11,7 +11,7 @@ const main = {
| `std.Some bio: f = bio
| `std.None: std.fatal(1, "Unable to open data file")
;;
-
+
/* write a 5 byte chunk */
bio.write(f, "test\n")
@@ -23,9 +23,10 @@ const main = {
buf[i] = 0x31
;;
bio.write(f, buf[:])
-
+
/* final message after a big burst */
bio.write(f, "goodbye\n")
+ bio.flush(f)
/* and test for flush on close */
bio.close(f);