+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
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;
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;
}
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;
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);