string repreesenting file path.
max buffer size. default value is size_t.max.
a fuction called when operation finished or an error occurred.
1 import std.file : write, remove; 2 import dpromise.utils : runEventloop; 3 write("hoge.txt", "hogehogepiyopiyo"); 4 scope(exit) remove("hoge.txt"); 5 6 readAsyncWithCallback("hoge.txt", size_t.max, (data, e) nothrow { 7 try { 8 assert(e is null); 9 assert(data !is null); 10 11 assert(cast(string)data == "hogehogepiyopiyo"); 12 } catch(Exception e) {} 13 }); 14 15 readAsyncWithCallback("hoge.txt", 8, (data, e) nothrow { 16 try { 17 assert(e is null); 18 assert(data !is null); 19 20 assert(cast(string)data == "hogehoge"); 21 } catch(Exception e) {} 22 }); 23 24 runEventloop();
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 readAsyncWithCallback("hoge.txt", (data, e) nothrow { 8 try { 9 assert(e is null); 10 assert(data !is null); 11 12 assert(cast(string)data == "hogehogepiyopiyo"); 13 } catch(Exception e) {} 14 }); 15 16 runEventloop();
Read file path with asynchronous IO then calls the callback function. If file size is larger than up_to, only up_to bytes read.
If an error occurred, the callback function will be called with the error.