copy_async


Description:

public virtual async bool copy_async (File destination, FileCopyFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null, FileProgressCallback? progress_callback = null) throws Error

Copies the file this to the location specified by destination asynchronously.

For details of the behaviour, see copy.

If progress_callback is not null, then that function that will be called just like in copy. The callback will run in the default main context of the thread calling copy_async — the same context as callback is run in.

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

Example: Copy a file, async:

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

// Copy my-test-1.txt to my-test-2.txt:
File file1 = File.new_for_path ("my-test-1.txt");
File file2 = File.new_for_path ("my-test-2.txt");
file1.copy_async.begin (file2, 0, Priority.DEFAULT, null, (current_num_bytes, total_num_bytes) => {
// Report copy-status:
print ("%" + int64.FORMAT + " bytes of %" + int64.FORMAT + " bytes copied.\n",
current_num_bytes, total_num_bytes);
}, (obj, res) => {
try {
bool tmp = file1.copy_async.end (res);
print ("Result: %s\n", tmp.to_string ());
} catch (Error e) {
print ("Error: %s\n", e.message);
}

loop.quit ();
});

loop.run ();
return 0;
}

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

Parameters:

this

input File

destination

destination File

flags

set of FileCopyFlags

io_priority

the I/O priority of the request

cancellable

optional Cancellable object, null to ignore

progress_callback

function to callback with progress information, or null if progress information is not needed

callback

a TaskReadyCallback to call when the request is satisfied

progress_callback_data

user data to pass to progress_callback

user_data

the data to pass to callback