from http://valadoc.org/#!api=gio-2.0/GLib.Seekable
seek on FileIOStream run without error but seeking with DataInputStream
throw an error.... but none on Windows... :-?
I will try to change my source code to test.

code sample.vala
public static int main (string[] args) {
        File file = File.new_for_path ("my-test.txt");

        try {
                FileIOStream ios =  file.open_readwrite();

        // no error
                assert (ios.can_seek ());
        // no error
                ios.seek (11, SeekType.SET);

                InputStream @is = ios.input_stream;
                DataInputStream dis = new DataInputStream (@is);

                string line;
                while ((line = dis.read_line ()) != null) {
                        stdout.puts (line);
                        stdout.putc ('\n');
                }

                // display error
                dis.seek(0,SeekType.SET);

        } catch (Error e) {
                stdout.printf ("Error: %s\n", e.message);
        }

        return 0;
}


OUTPUT

$ cat my-test.txt
My first line
My second line

$ valac --pkg gio-2.0 sample.vala
cyriac@arche:~/src$ ./sample
ne
My second line

(process:29159): GLib-GIO-CRITICAL **: g_seekable_seek: assertion
`G_IS_SEEKABLE (seekable)' failed

> I've downloaded source tarball of Vala 0.22, compiled and install it but
> no effect... :-/
>
> I was wondering if it was not a system problem. But I can not admit that I
> would have to reinstall linux to make it work. I'll search for reinstall
> only glib....
>
> Thanks
>
> Raum
>
>> Seems like it is problem with glib2 package, try to reinstall it, I
>> can't
>> say how it exactly called in Ubuntu, because I'm not an Ubuntu user.
>>                                                                              
>>                                                                              
>>                                                                              
>>   From:
>> [email protected]:
>> ??????,
>> 26
>> ??????
>> 2013
>> ?.
>> 22:17To:
>> [email protected]:
>> Re:
>> [Vala]
>> [Fwd:
>> Binary
>> File
>> is
>> not
>> seekable
>> ?!?]
>> Hello,
>>
>> Let me explain. I want to create a tool for Linux and Windows.
>>
>> I need to open a binary file and seek to a position... With MingW on
>> Windows, it runs without error but on Linux, I've a "seekable" error
>> with
>> the same code, same compile options, etc.
>>
>> I dont understand why...
>>
>> ##### Code
>>
>>  public void main() {
>>     try {
>>        File file = File.new_for_path ("test.pcap");
>>        DataInputStream dis = new DataInputStream (file.read ());
>>        stdout.printf("seekable: %s\n",(dis.can_seek())?"true":"false");
>>     } catch (Error e) {
>>     }
>>  }
>>
>> ##### WINDOWS 32bits / MingW32
>>
>> $ valac --pkg gio-2.0 seek.vala
>> $ ./seek
>> seekable: true
>>
>> ###### LINUX -Ubuntu 13.03- 64 bits
>>
>> $ valac --pkg gio-2.0 seek.vala
>> $ ./seek
>> (process:8097): GLib-GIO-CRITICAL **: g_seekable_can_seek: assertion
>> `G_IS_SEEKABLE (seekable)' failed
>> seekable: false
>>
>>
>> Do you have an idea why it's running on Windows but not on Linux ?
>>
>> Thanks
>>
>> Raum
>> _______________________________________________
>> vala-list mailing list
>>
>> https://mail.gnome.org/mailman/listinfo/vala-list
>>
>
> _______________________________________________
> vala-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/vala-list
>

_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to