static void fr_command_zip_test (FrCommand *comm) { fr_process_begin_command (comm->process, "unzip"); fr_process_add_arg (comm->process, "-t"); add_password_arg (comm, comm->password); fr_process_add_arg (comm->process, comm->filename); fr_process_end_command (comm->process); }
static void fr_command_7z_extract (FrCommand *command, const char *from_file, GList *file_list, const char *dest_dir, gboolean overwrite, gboolean skip_older, gboolean junk_paths) { FrArchive *archive = FR_ARCHIVE (command); GList *scan; fr_process_use_standard_locale (command->process, TRUE); fr_process_set_out_line_func (command->process, process_line__extract, command); fr_command_7z_begin_command (command); if (junk_paths) fr_process_add_arg (command->process, "e"); else fr_process_add_arg (command->process, "x"); fr_process_add_arg (command->process, "-bd"); fr_process_add_arg (command->process, "-y"); add_password_arg (command, archive->password, FALSE); if (dest_dir != NULL) fr_process_add_arg_concat (command->process, "-o", dest_dir, NULL); if (from_file != NULL) fr_process_add_arg_concat (command->process, "-i@", from_file, NULL); if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) /* Files prefixed with '@' need to be handled specially */ if (g_str_has_prefix (scan->data, "@")) fr_process_add_arg_concat (command->process, "-i!", scan->data, NULL); fr_process_add_arg (command->process, "--"); fr_process_add_arg (command->process, command->filename); if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) /* Skip files prefixed with '@', already added */ if (!g_str_has_prefix (scan->data, "@")) fr_process_add_arg (command->process, scan->data); fr_process_end_command (command->process); }
static void fr_command_7z_test (FrCommand *command) { FrArchive *archive = FR_ARCHIVE (command); fr_command_7z_begin_command (command); fr_process_add_arg (command->process, "t"); fr_process_add_arg (command->process, "-bd"); fr_process_add_arg (command->process, "-y"); add_password_arg (command, archive->password, FALSE); fr_process_add_arg (command->process, "--"); fr_process_add_arg (command->process, command->filename); fr_process_end_command (command->process); }
static void fr_command_zip_add (FrCommand *comm, const char *from_file, GList *file_list, const char *base_dir, gboolean update, gboolean recursive) { GList *scan; fr_process_set_out_line_func (FR_COMMAND (comm)->process, process_line__common, comm); fr_process_begin_command (comm->process, "zip"); if (base_dir != NULL) fr_process_set_working_dir (comm->process, base_dir); /* preserve links. */ fr_process_add_arg (comm->process, "-y"); if (update) fr_process_add_arg (comm->process, "-u"); add_password_arg (comm, comm->password); switch (comm->compression) { case FR_COMPRESSION_VERY_FAST: fr_process_add_arg (comm->process, "-1"); break; case FR_COMPRESSION_FAST: fr_process_add_arg (comm->process, "-3"); break; case FR_COMPRESSION_NORMAL: fr_process_add_arg (comm->process, "-6"); break; case FR_COMPRESSION_MAXIMUM: fr_process_add_arg (comm->process, "-9"); break; } fr_process_add_arg (comm->process, comm->filename); fr_process_add_arg (comm->process, "--"); for (scan = file_list; scan; scan = scan->next) fr_process_add_arg (comm->process, scan->data); fr_process_end_command (comm->process); }
static void fr_command_zip_extract (FrCommand *comm, const char *from_file, GList *file_list, const char *dest_dir, gboolean overwrite, gboolean skip_older, gboolean junk_paths) { GList *scan; fr_process_set_out_line_func (FR_COMMAND (comm)->process, process_line__common, comm); fr_process_begin_command (comm->process, "unzip"); if (dest_dir != NULL) { fr_process_add_arg (comm->process, "-d"); fr_process_add_arg (comm->process, dest_dir); } if (overwrite) fr_process_add_arg (comm->process, "-o"); else fr_process_add_arg (comm->process, "-n"); if (skip_older) fr_process_add_arg (comm->process, "-u"); if (junk_paths) fr_process_add_arg (comm->process, "-j"); add_password_arg (comm, comm->password); fr_process_add_arg (comm->process, "--"); fr_process_add_arg (comm->process, comm->filename); for (scan = file_list; scan; scan = scan->next) { char *escaped; escaped = escape_str (scan->data, ZIP_SPECIAL_CHARACTERS); fr_process_add_arg (comm->process, escaped); g_free (escaped); } fr_process_end_command (comm->process); }
static void fr_command_7z_delete (FrCommand *command, const char *from_file, GList *file_list) { FrArchive *archive = FR_ARCHIVE (command); GList *scan; fr_command_7z_begin_command (command); fr_process_add_arg (command->process, "d"); fr_process_add_arg (command->process, "-bd"); fr_process_add_arg (command->process, "-y"); if (_g_mime_type_matches (FR_ARCHIVE (command)->mime_type, "application/x-ms-dos-executable")) fr_process_add_arg (command->process, "-sfx"); if (_g_mime_type_matches (archive->mime_type, "application/zip") || _g_mime_type_matches (archive->mime_type, "application/x-cbz")) { fr_process_add_arg (command->process, "-tzip"); } if (from_file != NULL) fr_process_add_arg_concat (command->process, "-i@", from_file, NULL); if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) /* Files prefixed with '@' need to be handled specially */ if (g_str_has_prefix (scan->data, "@")) fr_process_add_arg_concat (command->process, "-i!", scan->data, NULL); add_password_arg (command, FR_ARCHIVE (command)->password, FALSE); fr_process_add_arg (command->process, "--"); fr_process_add_arg (command->process, command->filename); if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) /* Skip files prefixed with '@', already added */ if (!g_str_has_prefix (scan->data, "@")) fr_process_add_arg (command->process, scan->data); fr_process_end_command (command->process); }
static gboolean fr_command_7z_list (FrCommand *command) { rar_check_multi_volume (command); fr_process_set_out_line_func (command->process, list__process_line, command); fr_command_7z_begin_command (command); fr_process_set_begin_func (command->process, list__begin, command); fr_process_add_arg (command->process, "l"); fr_process_add_arg (command->process, "-slt"); fr_process_add_arg (command->process, "-bd"); fr_process_add_arg (command->process, "-y"); add_password_arg (command, FR_ARCHIVE (command)->password, FALSE); fr_process_add_arg (command->process, "--"); fr_process_add_arg (command->process, command->filename); fr_process_end_command (command->process); return TRUE; }
static void fr_command_7z_add (FrCommand *command, const char *from_file, GList *file_list, const char *base_dir, gboolean update, gboolean follow_links) { FrArchive *archive = FR_ARCHIVE (command); GList *scan; fr_process_use_standard_locale (command->process, TRUE); fr_process_set_out_line_func (command->process, process_line__add, command); fr_command_7z_begin_command (command); if (update) fr_process_add_arg (command->process, "u"); else fr_process_add_arg (command->process, "a"); if (base_dir != NULL) fr_process_set_working_dir (command->process, base_dir); if (_g_mime_type_matches (archive->mime_type, "application/zip") || _g_mime_type_matches (archive->mime_type, "application/x-cbz")) { fr_process_add_arg (command->process, "-tzip"); fr_process_add_arg (command->process, "-mem=AES128"); } fr_process_add_arg (command->process, "-bd"); fr_process_add_arg (command->process, "-y"); if (follow_links) fr_process_add_arg (command->process, "-l"); add_password_arg (command, archive->password, FALSE); if ((archive->password != NULL) && (*archive->password != 0) && archive->encrypt_header && fr_archive_is_capable_of (archive, FR_ARCHIVE_CAN_ENCRYPT_HEADER)) { fr_process_add_arg (command->process, "-mhe=on"); } /* fr_process_add_arg (command->process, "-ms=off"); FIXME: solid mode off? */ switch (archive->compression) { case FR_COMPRESSION_VERY_FAST: fr_process_add_arg (command->process, "-mx=1"); break; case FR_COMPRESSION_FAST: fr_process_add_arg (command->process, "-mx=5"); break; case FR_COMPRESSION_NORMAL: fr_process_add_arg (command->process, "-mx=7"); break; case FR_COMPRESSION_MAXIMUM: fr_process_add_arg (command->process, "-mx=9"); if (! _g_mime_type_matches (archive->mime_type, "application/zip") && ! _g_mime_type_matches (archive->mime_type, "application/x-cbz")) { fr_process_add_arg (command->process, "-m0=lzma2");; } break; } if (_g_mime_type_matches (archive->mime_type, "application/x-ms-dos-executable")) fr_process_add_arg (command->process, "-sfx"); if (archive->volume_size > 0) fr_process_add_arg_printf (command->process, "-v%ub", archive->volume_size); if (from_file != NULL) fr_process_add_arg_concat (command->process, "-i@", from_file, NULL); if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) /* Files prefixed with '@' need to be handled specially */ if (g_str_has_prefix (scan->data, "@")) fr_process_add_arg_concat (command->process, "-i!", scan->data, NULL); fr_process_add_arg (command->process, "--"); fr_process_add_arg (command->process, command->filename); if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) /* Skip files prefixed with '@', already added */ if (!g_str_has_prefix (scan->data, "@")) fr_process_add_arg (command->process, scan->data); fr_process_end_command (command->process); }