string repreesenting file path.
data to be written to file.
a fuction called when operation finished or an error occurred.
1 import std.file : exists, readText, remove; 2 import dpromise.utils : runEventloop; 3 writeAsyncWithCallback("hoge.txt", "hogehogepiyopiyo", (e) nothrow { 4 try { 5 assert(e is null); 6 assert(exists("hoge.txt")); 7 assert(readText("hoge.txt") == "hogehogepiyopiyo"); 8 9 scope(exit) { 10 remove("hoge.txt"); 11 } 12 } catch(Exception e) {} 13 }); 14 15 runEventloop();
Writes buffer to file path then calls the callback function with data as untyped array.
Creates a new file if it is not already exist. If an error occurred, the callback function will be called with the error.