Converting clib FILE stream in GFileInputStream

View: New views
4 Messages — Rating Filter:   Alert me  

Converting clib FILE stream in GFileInputStream

by Martin Kalbfuß :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi again.

Is it possible to convert a stadnard FILE stream into an
GFileInputStream and vice versa? The allegro library has functions to
read/write bitmaps in different formats to/from a FILE stream. I would
like to use this functions on GFileStreams.

Thanks,
Martin

_______________________________________________
gtk-list mailing list
gtk-list@...
http://mail.gnome.org/mailman/listinfo/gtk-list

Re: Converting clib FILE stream in GFileInputStream

by Shaun McCance-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 2009-11-09 at 21:44 +0100, Martin Kalbfuß wrote:
> Hi again.
>
> Is it possible to convert a stadnard FILE stream into an
> GFileInputStream and vice versa? The allegro library has functions to
> read/write bitmaps in different formats to/from a FILE stream. I would
> like to use this functions on GFileStreams.

Do you really need a GFileInputStream, or just some sort of
GInputStream?  To get an input stream from a file descriptor,
there's GUnixInputStream:

http://library.gnome.org/devel/gio/stable/GUnixInputStream.html

--
Shaun


_______________________________________________
gtk-list mailing list
gtk-list@...
http://mail.gnome.org/mailman/listinfo/gtk-list

Re: Converting clib FILE stream in GFileInputStream

by Martin Kalbfuß :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Montag, den 09.11.2009, 15:05 -0600 schrieb Shaun McCance:

> On Mon, 2009-11-09 at 21:44 +0100, Martin Kalbfuß wrote:
> > Hi again.
> >
> > Is it possible to convert a stadnard FILE stream into an
> > GFileInputStream and vice versa? The allegro library has functions to
> > read/write bitmaps in different formats to/from a FILE stream. I would
> > like to use this functions on GFileStreams.
>
> Do you really need a GFileInputStream, or just some sort of
> GInputStream?  To get an input stream from a file descriptor,
> there's GUnixInputStream:
>
> http://library.gnome.org/devel/gio/stable/GUnixInputStream.html
>
> --
> Shaun
>
>

Thanks Shaun.

Wouldn't that be platform specific? I'm new to the GTK+ world so I'm
still confused about which file to use. Currently that's even not that
important, because the other library I use has it's own stream type like
GIO has and it hasn't the ability to convert it to a standard file
stream. So mixing the two APIs isn't possible. What a shame.

_______________________________________________
gtk-list mailing list
gtk-list@...
http://mail.gnome.org/mailman/listinfo/gtk-list

Re: Converting clib FILE stream in GFileInputStream

by Behdad Esfahbod-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/10/2009 06:32 PM, Martin Kalbfuß wrote:
>
> Wouldn't that be platform specific? I'm new to the GTK+ world so I'm
> still confused about which file to use. Currently that's even not that
> important, because the other library I use has it's own stream type like
> GIO has and it hasn't the ability to convert it to a standard file
> stream. So mixing the two APIs isn't possible. What a shame.

Sure you can.  Just create a GMemoryInputStream or GMemoryOutputStream
depending on the direction of the data flow between the two APIs.

If using GMemoryInputStream, in the write callback from your other API, you
call g_memory_input_stream_add_data() (perhaps on a copy of the data).

If using GMemoryOutputStream, humm, seems like the API doesn't provide a
callback for this one.

Regardless, you can definitely subclass GInputStream / GOutputStream yourself
to achieve what you want.

behdad
_______________________________________________
gtk-list mailing list
gtk-list@...
http://mail.gnome.org/mailman/listinfo/gtk-list