Re: [Vala] Vala 0.11.6 How do I copy a file using GInputStream and GOutputStream?
- From: pancake <pancake youterm com>
- To: Graham Whelan <gawhelan gmail com>
- Cc: "vala-list gnome org" <vala-list gnome org>
- Subject: Re: [Vala] Vala 0.11.6 How do I copy a file using GInputStream and GOutputStream?
- Date: Wed, 2 Mar 2011 16:10:37 +0100
Yes. It is a bug. Please report it :)
Btw.. When are the opened bugs going to be reviewed and commited? I can count many ready-to-commit bugreports.
On 02/03/2011, at 12:21, Graham Whelan <gawhelan gmail com> wrote:
On 1 March 2011 19:58, Graham Whelan <gawhelan gmail com> wrote:
On 1 March 2011 18:29, Jürg Billeter <j bitron ch> wrote:
On Tue, 2011-03-01 at 18:21 +0000, Graham Whelan wrote:
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);
This should work with slicing:
output.write (buffer[0:read]);
Jürg
Thanks for the quick response.
I've just tried your suggestion with valac 0.11.5 and 0.11.6 but it
doesn't work. Looking at the generated C code, Vala is still passing
the full length of the array and not the length of the slice.
So:
output.write (buffer[0:read]);
becomes:
g_output_stream_write ((GOutputStream*) output, buffer + 0, (gsize)
4096, NULL, &_inner_error_);
Graham
I've managed to get this to work by using a variable rather than
fixed-size array.
The sample code becomes:
uint8[] buffer = new uint8[4096];
size_t read;
while(true) {
read = input.read(buffer);
if (read > 0) {
output.write (buffer[0:read]);
} else {
break;
}
}
With a fixed-size array the slice operation doesn't work. Is this a bug?
Thanks for the help,
Graham
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]