[libgsf] gsf: cleanups.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] gsf: cleanups.
- Date: Thu, 27 Nov 2014 23:43:33 +0000 (UTC)
commit 42356ed8b36a2b1d1627971c4657b17edeca1485
Author: Morten Welinder <terra gnome org>
Date: Thu Nov 27 18:43:12 2014 -0500
gsf: cleanups.
ChangeLog | 7 +++++++
gsf/gsf-input.c | 17 ++++++++---------
tools/gsf.c | 6 +++++-
3 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9dc6c91..6507bd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-11-27 Morten Welinder <terra gnome org>
+
+ * gsf/gsf-input.c (gsf_input_copy): Minor cleanups.
+
+ * tools/gsf.c (load_recursively): Complain if gsf_input_copy
+ fails.
+
2014-11-23 Morten Welinder <terra gnome org>
* gsf/gsf-infile-zip.c (zip_dirent_new_in): Fix reading of
diff --git a/gsf/gsf-input.c b/gsf/gsf-input.c
index 0590033..f9b777d 100644
--- a/gsf/gsf-input.c
+++ b/gsf/gsf-input.c
@@ -677,20 +677,19 @@ gsf_input_error (void)
gboolean
gsf_input_copy (GsfInput *input, GsfOutput *output)
{
- gsf_off_t remaining = 0;
- gsf_off_t toread = 0;
- const guint8 * buffer = NULL;
- gboolean success = TRUE;
+ gboolean success = TRUE;
+ gsf_off_t remaining;
g_return_val_if_fail (input != NULL, FALSE);
g_return_val_if_fail (output != NULL, FALSE);
- while ((remaining = gsf_input_remaining (input)) > 0 && (success)) {
- toread = MIN (remaining, GSF_READ_BUFSIZE);
- if (NULL == (buffer = gsf_input_read (input, toread, NULL)))
- success = FALSE;
- else
+ while (success && (remaining = gsf_input_remaining (input)) > 0) {
+ gsf_off_t toread = MIN (remaining, GSF_READ_BUFSIZE);
+ const guint8 * buffer = gsf_input_read (input, toread, NULL);
+ if (buffer)
success = gsf_output_write (output, toread, buffer);
+ else
+ success = FALSE;
}
return success;
diff --git a/tools/gsf.c b/tools/gsf.c
index f8e58d5..bcf4471 100644
--- a/tools/gsf.c
+++ b/tools/gsf.c
@@ -417,6 +417,7 @@ load_recursively (GsfOutfile *outfile, char const *path)
char *base;
GsfInput *in;
GsfOutput *out;
+ gboolean ok;
in = gsf_input_stdio_new (path, &error);
if (!in) {
@@ -430,11 +431,14 @@ load_recursively (GsfOutfile *outfile, char const *path)
"modtime", gsf_input_get_modtime (in),
NULL);
g_printerr ("Adding %s\n", path);
- gsf_input_copy (in, out);
+ ok = gsf_input_copy (in, out);
gsf_output_close (out);
g_object_unref (out);
g_free (base);
+ if (!ok)
+ g_printerr ("Error in adding member.\n");
+
g_object_unref (in);
} else {
g_printerr ("Ignoring %s\n", path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]