readTextAsync

Read file path with asynchronous IO and return data read as a promise of string(validate with std.utf.validate)

If an error occurred, the promise will be rejected.

nothrow
Promise!S
readTextAsync
(
S = string
)
(
string path
)
if (
isSomeString!S
)

Parameters

path
Type: string

string representing file path.

Return Value

Type: Promise!S

A promise of string read.

Examples

1 import std.file : write, remove;
2 import dpromise.utils : runEventloop;
3 
4 write("hoge.txt", "hogehogepiyopiyo");
5 scope(exit) remove("hoge.txt");
6 
7 readTextAsync("hoge.txt").then(
8   (s) {
9     assert(s == "hogehogepiyopiyo");
10   }
11 );
12 
13 runEventloop();

See Also

Meta