summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-12-18 14:35:14 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2013-01-09 13:56:07 +0100
commit0a97c9f43718d34aacc834c60f3ced60e9ce956f (patch)
tree7a5b5975cd92862283df669f9af62005fe63baa9 /tools
parent880b9016b1d751d480a282b9a8556c54701a86f4 (diff)
downloadmsitools-0a97c9f43718d34aacc834c60f3ced60e9ce956f.tar.gz
msitools-0a97c9f43718d34aacc834c60f3ced60e9ce956f.tar.xz
msitools-0a97c9f43718d34aacc834c60f3ced60e9ce956f.zip
record: add set_stream() and get_stream() using GIO
Use GInputStream for record stream manipulation
Diffstat (limited to 'tools')
-rw-r--r--tools/msiinfo.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/tools/msiinfo.c b/tools/msiinfo.c
index eb44035..9448ce0 100644
--- a/tools/msiinfo.c
+++ b/tools/msiinfo.c
@@ -371,6 +371,8 @@ static int cmd_extract(struct Command *cmd, int argc, char **argv, GError **erro
LibmsiDatabase *db = NULL;
LibmsiQuery *query = NULL;
LibmsiRecord *rec = NULL;
+ GOutputStream *out = NULL;
+ GInputStream *in = NULL;
int r = 1;
char *buf;
unsigned size, bufsize;
@@ -398,26 +400,23 @@ static int cmd_extract(struct Command *cmd, int argc, char **argv, GError **erro
if (*error)
goto end;
- if (!libmsi_record_save_stream(rec, 1, NULL, &size))
- exit(1);
-
- bufsize = (size > 1048576 ? 1048576 : size);
- buf = g_malloc(bufsize);
-
#if O_BINARY
_setmode(STDOUT_FILENO, O_BINARY);
#endif
- while (size > 0) {
- r = libmsi_record_save_stream(rec, 1, buf, &bufsize);
- assert(size >= bufsize);
- full_write(STDOUT_FILENO, buf, bufsize);
- size -= bufsize;
- }
+ out = g_unix_output_stream_new(STDOUT_FILENO, FALSE);
+ in = G_INPUT_STREAM (libmsi_record_get_stream(rec, 1));
+ if (g_output_stream_splice(out, in, 0, NULL, error) == -1)
+ goto end;
- r = 0;
+ if (!*error)
+ r = 0;
end:
+ if (out)
+ g_object_unref(out);
+ if (in)
+ g_object_unref(in);
if (rec)
g_object_unref(rec);
if (query)