append_to_async


Description:

public virtual async FileOutputStream append_to_async (FileCreateFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error

Asynchronously opens this for appending.

For more details, see append_to which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call append_to_async.end to get the result of the operation.

Example: Append to file, async:

public static int main (string[] args) {
MainLoop loop = new MainLoop ();

// Open or create a file for appending:
File file = File.new_for_path ("my-test.txt");
file.append_to_async.begin (FileCreateFlags.NONE, Priority.DEFAULT, null, (obj, res) => {;
try {
// Append a new line on each run:
FileOutputStream os = file.append_to_async.end (res);
os.write ("My new line\n".data);
} catch (Error e) {
print ("Error: %s\n", e.message);
}

loop.quit ();
});

loop.run ();
return 0;
}

valac --pkg gio-2.0 GLib.File.append_to_async.vala

Parameters:

this

input File

flags

a set of FileCreateFlags

io_priority

the I/O priority of the request

cancellable

optional Cancellable object, null to ignore

callback

a TaskReadyCallback to call when the request is satisfied

user_data

the data to pass to callback function