More file IO!

Can now create, delete, and write to files.
This commit is contained in:
Bob Nystrom
2016-02-20 09:23:42 -08:00
parent bec5181bdb
commit 8e90e3577b
21 changed files with 463 additions and 52 deletions
+25
View File
@@ -0,0 +1,25 @@
import "io" for File
// Create a new file.
var f
File.create("file.temp") {|file|
f = file
System.print(file.isOpen) // expect: true
System.print(file.size) // expect: 0
file.writeBytes("stuff")
}
// Closed on block exit.
System.print(f.isOpen) // expect: false
System.print(File.size("file.temp")) // expect: 5
// Overwrite a file.
File.create("file.temp") {|file|
// Truncates.
System.print(file.size) // expect: 0
}
File.delete("file.temp")
// TODO: Test return value.