string repreesenting file path.
max buffer size. default value is size_t.max.
a fuction called when operation finished or an error occurred.
import std.file : write, remove; import dpromise.utils : runEventloop; write("hoge.txt", "hogehogepiyopiyo"); scope(exit) remove("hoge.txt"); readAsyncWithCallback("hoge.txt", size_t.max, (data, e) nothrow { try { assert(e is null); assert(data !is null); assert(cast(string)data == "hogehogepiyopiyo"); } catch(Exception e) {} }); readAsyncWithCallback("hoge.txt", 8, (data, e) nothrow { try { assert(e is null); assert(data !is null); assert(cast(string)data == "hogehoge"); } catch(Exception e) {} }); runEventloop();
import std.file : write, remove; import dpromise.utils : runEventloop; write("hoge.txt", "hogehogepiyopiyo"); scope(exit) remove("hoge.txt"); readAsyncWithCallback("hoge.txt", (data, e) nothrow { try { assert(e is null); assert(data !is null); assert(cast(string)data == "hogehogepiyopiyo"); } catch(Exception e) {} }); 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.