AsyncFile

Runs all blocking file I/O commands in a thread pool and calls the handler upon completion.

Constructors

this
this(EventLoop evl)

Members

Functions

append
bool append(string file_path, shared ubyte[] buffer, bool create_if_not_exists = true, bool truncate_if_exists = false)

Appends the data from the buffer into a file at the specified path.

buffer
shared(ubyte[]) buffer()

Retrieve the buffer from the last command. Must be called upon completion.

kill
bool kill()

Cleans up the underlying resources. todo: make this dispose?

onReady
shared(typeof(this)) onReady(void delegate() del)

Sets the handler called by the owner thread's event loop after the command is completed.

read
bool read(string file_path, shared ubyte[] buffer, ulong off = -1, bool create_if_not_exists = true, bool truncate_if_exists = false)

Reads the file into the buffer starting at offset byte position.

read
bool read(string file_path, size_t len = 128, ulong off = -1, bool create_if_not_exists = true, bool truncate_if_exists = false)

Creates a new buffer with the specified length and uses it to read the file data at the specified path starting at the specified offset byte.

write
bool write(string file_path, shared const(ubyte)[] buffer, ulong off = -1, bool create_if_not_exists = true, bool truncate_if_exists = false)

Writes the data from the buffer into the file at the specified path starting at the given offset byte position.

Properties

error
string error [@property getter]
offset
ulong offset [@property getter]

The current offset updated after the command execution

status
StatusInfo status [@property getter]

Meta