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/presentation.c | |
parent | 6ac2b9d58e9105e4e2ab9736d34e7979dffecc6d (diff) |
Use GFile to save presentations
Diffstat (limited to 'src/presentation.c')
-rw-r--r-- | src/presentation.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/presentation.c b/src/presentation.c index d338a1a..bc0089f 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -127,22 +127,22 @@ struct presentation *new_presentation(const char *imagestore) int save_presentation(struct presentation *p, GFile *file) { - FILE *fh; - char *filename; - - /* FIXME: Do this properly using GFile */ - filename = g_file_get_path(file); - printf("Saving to %s\n", filename); + GFileOutputStream *fh; + int r; + GError *error = NULL; - fh = fopen(filename, "w"); - if ( fh == NULL ) return 1; + fh = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error); + if ( fh == NULL ) { + fprintf(stderr, "Open failed: %s\n", error->message); + return 1; + } + r = save_sc_block(G_OUTPUT_STREAM(fh), p->scblocks); + g_object_unref(fh); - save_sc_block(fh, p->scblocks); + if ( r ) return 1; imagestore_set_parent(p->is, g_file_get_parent(file)); - p->filename = strdup(filename); - - fclose(fh); + p->filename = g_file_get_uri(file); p->saved = 1; update_titlebar(p->narrative_window); return 0; |