[Vala] Vala 0.11.6 How do I copy a file using GInputStream and GOutputStream?



Hi,

I'm trying to copy a file using GLib.InputStream and GLib.OutputStream
but the copied file ends up corrupted.

Sample code:

uint8 buffer[4096];
size_t read;
while (true) {
        read = input.read (buffer);
        if (read > 0) {
                output.write (buffer);
        } else {
                break;
        }
}


I believe the problem is that the OutputStream methods do not allow me
to specify how much of the supplied buffer to write and so the whole
buffer gets written each time. This leads to junk data at the end of
the copied file.

Is the current vapi wrong or am I missing something?

Thanks,

Graham Whelan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]