open_readwrite_async
Description:
[ Version ( since = "2.22" ) ]
public virtual async FileIOStream open_readwrite_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
public virtual async FileIOStream open_readwrite_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Example: Open an existing file for r/w, async:
public static int main (string[] args) {
if (args.length != 2) {
print ("%s FILE\n", args[0]);
return 0;
}
MainLoop loop = new MainLoop ();
File file = File.new_for_commandline_arg (args[1]);
file.open_readwrite_async.begin (Priority.DEFAULT, null, (obj, res) => {
try {
FileIOStream iostream = file.open_readwrite_async.end (res);
iostream.seek (0, SeekType.END);
OutputStream ostream = iostream.output_stream;
DataOutputStream dostream = new DataOutputStream (ostream);
dostream.put_string ("new-line\n");
} catch (Error e) {
print ("Error: %s\n", e.message);
}
loop.quit ();
});
loop.run ();
return 0;
}
valac --pkg gio-2.0 GLib.File.open_readwrite_async.vala