feat: add file create, delete, writeBytes and FileFlags class to IO module
Implement File.create() and File.delete() static methods with async libuv operations, add writeBytes() instance method for writing at offsets, introduce FileFlags constants class mirroring POSIX open() flags, refactor File.open() to accept flag parameters via openWithFlags(), and update documentation and module registration accordingly.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import "io" for File, Stat
|
||||
|
||||
// Create a file and don't close it.
|
||||
var file = File.create("file.temp")
|
||||
|
||||
File.delete("file.temp")
|
||||
|
||||
file.close()
|
||||
|
||||
// TODO: More graceful API to tell if a file exists.
|
||||
var error = Fiber.new {
|
||||
Stat.path("file.temp")
|
||||
}.try()
|
||||
System.print(error) // expect: no such file or directory
|
||||
Reference in New Issue
Block a user