#include <string.h>
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-xfer.h>
#include "comics-document.h"
#include "ev-document-misc.h"
GSList *page_names;
int n_pages;
char *extract_command;
+ gboolean regex_arg;
};
typedef struct _ComicsDocumentClass ComicsDocumentClass;
comics_document_document_thumbnails_iface_init);
} );
+static char *
+comics_regex_quote (const char *s)
+{
+ char *ret, *d;
+
+ d = ret = g_malloc (strlen (s) * 2 + 3);
+
+ *d++ = '\'';
+
+ for (; *s; s++, d++) {
+ switch (*s) {
+ case '?':
+ case '|':
+ case '[':
+ case ']':
+ case '*':
+ case '\\':
+ case '\'':
+ *d++ = '\\';
+ break;
+ }
+ *d = *s;
+ }
+
+ *d++ = '\'';
+ *d = '\0';
+
+ return ret;
+}
+
static gboolean
comics_document_load (EvDocument *document,
const char *uri,
/* FIXME, use proper cbr/cbz mime types once they're
* included in shared-mime-info */
- if (!strcmp (mime_type, "application/cbr")) {
+ if (!strcmp (mime_type, "application/x-cbr")) {
comics_document->extract_command =
g_strdup ("unrar p -c- -ierr");
list_files_command =
g_strdup_printf ("unrar vb -c- -- %s", quoted_file);
- } else if (!strcmp (mime_type, "application/cbz")) {
+ comics_document->regex_arg = FALSE;
+ } else if (!strcmp (mime_type, "application/x-cbz")) {
comics_document->extract_command =
g_strdup ("unzip -p -C");
list_files_command =
g_strdup_printf ("zipinfo -1 -- %s", quoted_file);
+ comics_document->regex_arg = TRUE;
}
g_free (quoted_file);
GError **error)
{
ComicsDocument *comics_document = COMICS_DOCUMENT (document);
- GnomeVFSURI *source, *target;
- GnomeVFSResult ret;
-
- source = gnome_vfs_uri_new (comics_document->archive);
- target = gnome_vfs_uri_new (uri);
-
- ret = gnome_vfs_xfer_uri (source, target,
- GNOME_VFS_XFER_DEFAULT,
- GNOME_VFS_XFER_ERROR_MODE_ABORT,
- GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
- NULL, NULL);
-
- gnome_vfs_uri_unref (source);
- gnome_vfs_uri_unref (target);
-
- return ret == GNOME_VFS_OK;
+
+ return ev_xfer_uri_simple (comics_document->archive, uri, error);
}
static int
char *command_line, *quoted_archive, *quoted_filename;
quoted_archive = g_shell_quote (comics_document->archive);
- quoted_filename = g_shell_quote (
- g_slist_nth_data (comics_document->page_names, page));
+ if (comics_document->regex_arg) {
+ quoted_filename = comics_regex_quote (
+ g_slist_nth_data (comics_document->page_names, page));
+ } else {
+ quoted_filename = g_shell_quote (
+ g_slist_nth_data (comics_document->page_names, page));
+ }
command_line = g_strdup_printf ("%s -- %s %s",
comics_document->extract_command,