Retoor software development Projects Research SearchXNG
Register Sign In

19 lines
401 B
Plaintext
Raw Normal View History

feat: add io module with File.size async stat and scheduler resume helpers Introduce a new built-in "io" module exposing a File class with a static size(path) method that performs asynchronous filesystem stat via libuv. The method uses a foreign function startSize_ to initiate the stat request and resumes the calling fiber through the scheduler upon completion. Extend the scheduler with schedulerResumeDouble and schedulerResumeString to support resuming fibers with numeric or string results. Include the generated io.wren.inc source, update the Xcode project to compile io.c and io.wren.inc, register the module in modules.c, and add a test file verifying synchronous-style async size calls and error handling.
2015-09-16 16:34:49 +02:00
import "io" for File
import "scheduler" for Scheduler
System.print(File.size("test/io/file/size.wren")) // expect: 401
// Runs asynchronously.
Scheduler.add {
System.print("async")
}
System.print(File.size("test/io/file/size.wren"))
// expect: async
// expect: 401
var error = Fiber.new {
System.print(File.size("nonexistent"))
}.try()
System.print(error) // expect: no such file or directory
Reference in New Issue Copy Permalink
5e63e65752
wren/test/io/file/size.wren
Response time: 40ms
Mail Licenses API