-
- /* RARLabs software */
- if (g_str_has_suffix (comics_document->selected_command, "unrar") &&
- !comics_document->flag_FLOSS) {
- comics_document->extract_command =
- g_strdup_printf ("%s p -c- -ierr",
- comics_document->selected_command);
- comics_document->list_command =
- g_strdup_printf ("%s vb -c- -- %s",
- comics_document->selected_command,
- quoted_file);
- comics_document->flag_temp = FALSE;
- comics_document->regex_arg = FALSE;
- g_free (quoted_file);
- return TRUE;
- }
-
- /* Gna! unrar */
- if (g_str_has_suffix (comics_document->selected_command, "unrar-free")||
- (g_str_has_suffix (comics_document->selected_command, "unrar") &&
- comics_document->flag_FLOSS)) {
-
- comics_document->flag_temp = TRUE;
-
- checksum =
- g_compute_checksum_for_string (G_CHECKSUM_MD5,
- comics_document->archive,
- -1);
- comics_document->dir = g_build_filename (ev_tmp_dir (),
- checksum, NULL);
- g_free (checksum);
- /* unrar-free can't create directories so we do it on its
- * behalf */
- if (g_mkdir_with_parents (comics_document->dir, 0700) != 0) {
- int errsv = errno;
- g_set_error (error,
- EV_DOCUMENT_ERROR,
- EV_DOCUMENT_ERROR_INVALID,
- _("Failed to create a temporary "
- "directory on “%s”: %s"),
- ev_tmp_dir (),
- g_strerror (errsv));
- g_free (quoted_file);
- comics_document->flag_temp = FALSE;
- g_free (comics_document->dir);
- return FALSE;
- }
-
- command_decompress_tmp =
- g_strdup_printf ("%s -xf %s %s",
- comics_document->selected_command,
- quoted_file,
+ quoted_command = g_shell_quote (comics_document->selected_command);
+
+ comics_document->extract_command =
+ g_strdup_printf (command_usage_def[type].extract,
+ quoted_command);
+ comics_document->list_command =
+ g_strdup_printf (command_usage_def[type].list,
+ quoted_command, quoted_file);
+ comics_document->offset = command_usage_def[type].offset;
+ if (command_usage_def[type].decompress_tmp) {
+ comics_document->dir = ev_mkdtemp ("evince-comics-XXXXXX", error);
+ if (comics_document->dir == NULL)
+ return FALSE;
+
+ /* unrar-free can't create directories, but ev_mkdtemp already created the dir */
+
+ comics_document->decompress_tmp =
+ g_strdup_printf (command_usage_def[type].decompress_tmp,
+ quoted_command, quoted_file,