Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2009-02-15 13:51:53 (GMT)
committer Christian Persch <chpe@src.gnome.org>2009-02-15 13:51:53 (GMT)
commit7b0368829c39a9c1d78a785164bfe1c5d1f9f6ff (patch)
tree366c844d064ee6e0c5d67aa9ccd665a4c74bc9b2
parent9a9e42bd0d8922c844d439b143524254ee5441b2 (diff)
Make sure to fill in @error on failure. Also, since this is exported in
* libdocument/ev-file-helpers.c: (compression_run): Make sure to fill in @error on failure. Also, since this is exported in public APIs, cope with the passed-in GError** being NULL. svn path=/trunk/; revision=3442
-rw-r--r--ChangeLog6
-rw-r--r--libdocument/ev-file-helpers.c26
2 files changed, 27 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 135e5a1..4a0fcf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-14 Christian Persch <chpe@gnome.org>
+
+ * libdocument/ev-file-helpers.c: (compression_run): Make sure to fill
+ in @error on failure. Also, since this is exported in public APIs,
+ cope with the passed-in GError** being NULL.
+
2009-02-13 Christian Persch <chpe@gnome.org>
* libdocument/ev-file-helpers.c: (get_mime_type_from_uri): NULL
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index 2546fe7..6a3d2fa 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -315,15 +315,22 @@ compression_run (const gchar *uri,
gchar *filename, *filename_dst;
gchar *cmd;
gint fd, pout;
+ GError *err = NULL;
if (type == EV_COMPRESSION_NONE)
return NULL;
cmd = g_find_program_in_path ((type == EV_COMPRESSION_BZIP2) ? BZIPCOMMAND : GZIPCOMMAND);
- if (!cmd)
+ if (!cmd) {
+ /* FIXME: better error codes! */
+ /* FIXME: i18n later */
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ "Failed to find the \"%s\" command in the search path.",
+ type == EV_COMPRESSION_BZIP2 ? BZIPCOMMAND : GZIPCOMMAND);
return NULL;
+ }
- filename = g_filename_from_uri (uri, NULL, NULL);
+ filename = g_filename_from_uri (uri, NULL, error);
if (!filename) {
g_free (cmd);
return NULL;
@@ -332,9 +339,16 @@ compression_run (const gchar *uri,
filename_dst = g_build_filename (ev_tmp_dir (), "evinceXXXXXX", NULL);
fd = g_mkstemp (filename_dst);
if (fd < 0) {
+ int errsv = errno;
+
g_free (cmd);
g_free (filename);
g_free (filename_dst);
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ "Error creating a temporary file: %s",
+ g_strerror (errsv));
return NULL;
}
@@ -346,7 +360,7 @@ compression_run (const gchar *uri,
if (g_spawn_async_with_pipes (NULL, argv, NULL,
G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL, NULL,
- NULL, &pout, NULL, error)) {
+ NULL, &pout, NULL, &err)) {
GIOChannel *in, *out;
gchar buf[BUFFER_SIZE];
GIOStatus read_st, write_st;
@@ -380,8 +394,10 @@ compression_run (const gchar *uri,
close (fd);
- if (*error == NULL) {
- uri_dst = g_filename_to_uri (filename_dst, NULL, NULL);
+ if (err) {
+ g_propagate_error (error, err);
+ } else {
+ uri_dst = g_filename_to_uri (filename_dst, NULL, error);
}
g_free (cmd);