[Vala] (no subject)



Joss 4 wrote:
Jürg Billeter wrote:
[1] http://valadoc.org/?pkg=gio-2.0&element=GLib.File.append_to
[2] http://library.gnome.org/devel/gio/stable/GFile.html#g-file-append-to
Thank you Jurg,
I gave a little look at the links you post me, but I don't want only
append data but update ; I mean seek , read data record and write.
It's  up to me if set current file pointer to current or end.

I run into this problem again and again with Vala. First when I did an
ELF parser I needed to read an uint32 from a binary file and then seek
to it, and later when I was working on a TIF/EXIF parser I ran into the
same problem again (that file format also needs .read_uint32 + .seek).

With Vala streams you currently have to choose either "seek support"
or "ability to read binary data" because DataInputStream etc doesn't
inherit Seekable.

The root cause is in glib though and not in Vala itself. Some glib dev
pointed out that supporting seekable data input streams would be a nice
addition to glib in case anyone wants to contribute such patches:
http://www.nabble.com/Re%3A-Why-doesn%27t-DataInputStream-implement-Seekable---p20910384.html

The workaround that ended up doing is creating a new class called "binary
stream" (should probably be renamed to BinaryInputStream or maybe
SeekableDataInputStream though) that holds both a seekable base stream and
then after each seek it re-creates a datainputstream wrapper around it:
http://bitbucket.org/martin/projs/src/tip/vala/exif_utils/libvexif/binarystream.vala

I'd much rather see a solution in glib though so that everyone can
benefit from it.


                Martin




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