[gcab] cabinet: avoid seeking in empty streams, to allow growing output
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab] cabinet: avoid seeking in empty streams, to allow growing output
- Date: Fri, 4 Jan 2013 22:58:00 +0000 (UTC)
commit 74bdb5fe07a0a3caa2342ff94e5ccdc80b563ca3
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Jan 4 23:44:28 2013 +0100
cabinet: avoid seeking in empty streams, to allow growing output
libgcab/gcab-cabinet.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/libgcab/gcab-cabinet.c b/libgcab/gcab-cabinet.c
index 3dab4de..3d1a0c7 100644
--- a/libgcab/gcab-cabinet.c
+++ b/libgcab/gcab-cabinet.c
@@ -150,6 +150,7 @@ gcab_cabinet_write (GCabCabinet *self,
GInputStream *in = NULL;
GDataOutputStream *dstream = NULL;
gboolean success = FALSE;
+ int i;
dstream = g_data_output_stream_new (out);
g_data_output_stream_set_byte_order (dstream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
@@ -163,9 +164,11 @@ gcab_cabinet_write (GCabCabinet *self,
folder.offsetdata = CFI_START + nfiles * 16 + sumstr;
folder.ndatab = gcab_folder_get_ndatablocks (cabfolder);
- if (!g_seekable_seek (G_SEEKABLE (out), folder.offsetdata,
- G_SEEK_SET, NULL, error))
- goto end;
+ /* avoid seeking to allow growing output streams */
+ for (i = 0; i < folder.offsetdata; i++)
+ if (!g_data_output_stream_put_byte (dstream, 0, cancellable, error))
+ goto end;
+
gssize len, offset = 0;
cdata_t block = { 0, };
guint8 data[DATABLOCKSIZE];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]