writeAsync

Writes buffer to file path with asynchronous IO.

Creates a new file if it is not already exist. If an error occurred, the promise will be rejected.

nothrow
Promise!void
writeAsync
(
string path
,
in void[] buffer
)

Parameters

path
Type: string

string repreesenting file path.

buffer
Type: void[]

data to be written to file.

Examples

1 import std.file : exists, readText, remove;
2 import dpromise.utils : runEventloop;
3 
4 writeAsync("hoge.txt", "hogehogepiyopiyo").then({
5   assert(exists("hoge.txt"));
6   assert(readText("hoge.txt") == "hogehogepiyopiyo");
7   remove("hoge.txt");
8 });
9 
10 runEventloop();

See Also

Meta