diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-04-01 21:00:27 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-04-01 21:00:27 +0200 |
commit | 246832231856f3873d12b0702c02019bab281938 (patch) | |
tree | 1d5e0f361ae7b4db6383b0367fc78fb2c70894a9 /src/sc_parse.c | |
parent | 6ac2b9d58e9105e4e2ab9736d34e7979dffecc6d (diff) |
Use GFile to save presentations
Diffstat (limited to 'src/sc_parse.c')
-rw-r--r-- | src/sc_parse.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/sc_parse.c b/src/sc_parse.c index 5a653cf..3212872 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -31,6 +31,7 @@ #include <stdio.h> #include <ctype.h> #include <glib.h> +#include <gio/gio.h> #include "sc_parse.h" @@ -410,18 +411,25 @@ char *serialise_sc_block(const SCBlock *bl) } -void save_sc_block(FILE *fh, const SCBlock *bl) +int save_sc_block(GOutputStream *fh, const SCBlock *bl) { while ( bl != NULL ) { + GError *error = NULL; char *a = serialise_sc_block(bl); + gssize r; if ( a == NULL ) { fprintf(stderr, "Failed to serialise block\n"); - return; + return 1; + } + r = g_output_stream_write(fh, a, strlen(a), NULL, &error); + if ( r == -1 ) { + fprintf(stderr, "Write failed: %s\n", error->message); + return 1; } - fputs(a, fh); free(a); bl = bl->next; } + return 0; } |