This class provides methods for asynchronous operations on files instances. For synchronous operations, see nusys.io.File. To obtain an instance of this class, use the async field of nusys.io.File.

var file = nusys.FileSystem.open("example.txt", "r");
file.async.readFile(contents -> trace(contents.toString()));

All methods here are asynchronous versions of the functions in nusys.io.File. Please see them for a description of the arguments and use of each method.

Any synchronous method that returns no value (Void return type) has an extra callback:Callback<NoData> argument.

Any synchronous method that returns a value has an extra callback:Callback<T> argument, where T is the return type of the synchronous method.

Errors are communicated through the callbacks or in some cases thrown immediately.

Methods

chmod (mode:FilePermissions, callback:Callback<NoData>):Void

chown (uid:Int, gid:Int, callback:Callback<NoData>):Void

close (callback:Callback<NoData>):Void

datasync (callback:Callback<NoData>):Void

readBuffer (buffer:Bytes, offset:Int, length:Int, position:Int, callback:Callback<{bytesRead:Int, buffer:Bytes}>):Void

readFile (callback:Callback<Bytes>):Void

stat (callback:Callback<FileStat>):Void

Available on cross

stat (callback:Callback<Stat>):Void

Available on eval

sync (callback:Callback<NoData>):Void

@:value({ len : 0 })truncate (len:Int = 0, callback:Callback<NoData>):Void

utimes (atime:Date, mtime:Date, callback:Callback<NoData>):Void

writeBuffer (buffer:Bytes, offset:Int, length:Int, position:Int, callback:Callback<{bytesWritten:Int, buffer:Bytes}>):Void

writeString (str:String, ?position:Int, ?encoding:Encoding, callback:Callback<{bytesWritten:Int, buffer:Bytes}>):Void