After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 540459 - there are no way of getting the real number of bytes written in GMemoryOutputStream
there are no way of getting the real number of bytes written in GMemoryOutput...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.16.x
Other Linux
: Normal normal
: ---
Assigned To: Alexander Larsson
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-06-27 10:42 UTC by Akira TAGOH
Modified: 2008-06-30 03:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Akira TAGOH 2008-06-27 10:42:14 UTC
http://library.gnome.org/devel/gio/stable/GMemoryOutputStream.html#g-memory-output-stream-get-size says that I could achieve with g_seekable_seek() and g_seekable_tell() to get the number of bytes written in GMemoryOutputStream. but what I can get with g_seekable_tell() is the number of bytes allocated, not written.

$ cat t.c
#include <gio/gio.h>

int
main(void)
{
        GOutputStream *mo;
        GDataOutputStream *o;
        int i;
        GError *error = NULL;

        g_type_init();
        mo = g_memory_output_stream_new(NULL, 0, g_realloc, g_free);
        o = g_data_output_stream_new(mo);
        g_data_output_stream_put_byte(o, 1, NULL, NULL);
        g_seekable_seek(G_SEEKABLE (mo), 0, G_SEEK_END, NULL, NULL);
        g_print("%d\n", g_seekable_tell(G_SEEKABLE (mo)));
        g_object_unref(o);
        g_object_unref(mo);

        return 0;
}

$ gcc t.c `pkg-config --cflags --libs gio-2.0`
$ ./a.out
16
Comment 1 Matthias Clasen 2008-06-30 03:07:33 UTC
The docs should say G_SEEK_CUR, not G_SEEK_END.

I've fixed the doc comment in the 2.16 branch