void xa_7zip_delete (XArchive *archive,GSList *names) { gchar *command,*exe,*e_filename = NULL; GSList *list = NULL,*_names; GString *files = g_string_new(""); if (sevenzr) exe = "7zr d "; if (sevenza) exe = "7za d "; _names = names; while (_names) { e_filename = xa_escape_filename((gchar*)_names->data,"$'`\"\\!?* ()[]&|:;<>#"); g_string_prepend (files,e_filename); g_string_prepend_c (files,' '); _names = _names->next; } g_slist_foreach(names,(GFunc)g_free,NULL); g_slist_free(names); command = g_strconcat (exe,archive->escaped_path," ",files->str,NULL); g_string_free(files,TRUE); list = g_slist_append(list,command); xa_run_command (archive,list); if (archive->status == XA_ARCHIVESTATUS_DELETE) xa_reload_archive_content(archive); }
gboolean xa_7zip_extract(XArchive *archive,GSList *files) { gchar *command,*e_filename = NULL; GSList *list = NULL,*_files = NULL; GString *names = g_string_new(""); gboolean result = FALSE; _files = files; while (_files) { e_filename = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#"); g_string_prepend (names,e_filename); g_string_prepend_c (names,' '); _files = _files->next; } g_slist_foreach(_files,(GFunc)g_free,NULL); g_slist_free(_files); if (archive->passwd != NULL) command = g_strconcat ("7za " , archive->full_path ? "x" : "e", " -p",archive->passwd, archive->overwrite ? " -aoa" : " -aos", " -bd ", archive->escaped_path,names->str , " -o",archive->extraction_path,NULL); else command = g_strconcat ( "7za " , archive->full_path ? "x" : "e", archive->overwrite ? " -aoa" : " -aos", " -bd ", archive->escaped_path,names->str , " -o",archive->extraction_path,NULL); g_string_free(names,TRUE); list = g_slist_append(list,command); result = xa_run_command (archive,list); return result; }
void xa_tar_delete (XArchive *archive,GSList *files) { gchar *e_filename,*command = NULL; GSList *_files,*list = NULL; GString *names = g_string_new(""); _files = files; while (_files) { e_filename = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#"); g_string_prepend (names,e_filename); g_string_prepend_c (names,' '); _files = _files->next; } g_slist_foreach(files,(GFunc)g_free,NULL); g_slist_free(files); if (is_tar_compressed(archive->type)) xa_add_delete_bzip2_gzip_lzma_compressed_tar(names,archive,0); else { command = g_strconcat (tar, " --delete -vf ",archive->escaped_path," ",names->str,NULL); list = g_slist_append(list,command); xa_run_command (archive,list); if (archive->status == XA_ARCHIVESTATUS_DELETE) xa_reload_archive_content(archive); } }
gboolean xa_rpm_extract(XArchive *archive,GSList *files) { gchar *command = NULL,*e_filename = NULL; GSList *list = NULL,*_files = NULL; GString *names = g_string_new(""); gboolean result = FALSE; _files = files; while (_files) { e_filename = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#"); g_string_prepend (names,e_filename); g_string_prepend_c (names,' '); _files = _files->next; } g_slist_foreach(files,(GFunc)g_free,NULL); g_slist_free(files); chdir (archive->extraction_path); command = g_strconcat ( "sh -c \"cpio -id" , names->str," < ",archive->tmp,"/file.cpio\"",NULL); g_string_free(names,TRUE); list = g_slist_append(list,command); result = xa_run_command (archive,list); return result; }
gboolean xa_extract_tar_without_directories (gchar *string,XArchive *archive,gchar *files_to_extract) { gchar *command = NULL, *e_filename = NULL; GSList *list = NULL; GSList *files = NULL; GString *names = g_string_new(""); gboolean result; result = xa_create_temp_directory (archive); if (!result) return FALSE; if (strlen(files_to_extract) == 0) { gtk_tree_model_foreach(GTK_TREE_MODEL(archive->liststore),(GtkTreeModelForeachFunc) xa_concat_filenames,&files); while (files) { e_filename = xa_escape_filename((gchar*)files->data,"$'`\"\\!?* ()[]&|:;<>#"); g_string_prepend_c (names,' '); g_string_prepend (names,e_filename); files = files->next; } g_slist_foreach(files,(GFunc)g_free,NULL); g_slist_free(files); files_to_extract = names->str; } command = g_strconcat (string, archive->escaped_path, #ifdef __FreeBSD__ archive->overwrite ? " " : " -k", #else archive->overwrite ? " --overwrite" : " --keep-old-files", " --no-wildcards ", #endif archive->tar_touch ? " --touch" : "", "-C ",archive->tmp," ",files_to_extract,NULL); list = g_slist_append(list,command); if (strstr(files_to_extract,"/") || strcmp(archive->tmp,archive->extraction_path) != 0) { archive->working_dir = g_strdup(archive->tmp); command = g_strconcat ("mv -f ",files_to_extract," ",archive->extraction_path,NULL); list = g_slist_append(list,command); } g_string_free(names,TRUE); return xa_run_command (archive,list); }
gboolean xa_arj_extract(XArchive *archive,GSList *files) { gchar *command,*e_filename = NULL; GSList *list = NULL,*_files = NULL; GString *names = g_string_new(""); gboolean result = FALSE; _files = files; while (_files) { e_filename = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#"); g_string_prepend (names,e_filename); g_string_prepend_c (names,' '); _files = _files->next; } g_slist_foreach(_files,(GFunc)g_free,NULL); g_slist_free(_files); if (archive->passwd != NULL) command = g_strconcat ( "arj ",archive->full_path ? "x" : "e", " -g",archive->passwd, archive->overwrite ? "" : " -n" , " -i " , archive->freshen ? "-f " : "" , archive->update ? "-u " : " ", "-y ", archive->escaped_path , " ",archive->extraction_path,names->str,NULL); else { if (unarj) command = g_strconcat ( "sh -c \"cd ", archive->extraction_path, " && unarj ", archive->full_path ? "x" : "e", " ", archive->escaped_path, "\"", NULL ); else command = g_strconcat ( "arj ",archive->full_path ? "x" : "e", archive->overwrite ? "" : " -n" , " -i " , archive->freshen ? "-f " : "", archive->update ? "-u " : " ", "-y ", archive->escaped_path , " ",archive->extraction_path,names->str,NULL); } g_string_free(names,TRUE); list = g_slist_append(list,command); result = xa_run_command (archive,list); return result; }
gboolean xa_tar_extract(XArchive *archive,GSList *files) { gchar *command,*e_filename = NULL; GSList *list = NULL,*_files = NULL; GString *names = g_string_new(""); gboolean result = FALSE; _files = files; while (_files) { e_filename = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#"); g_string_prepend_c (names,' '); g_string_prepend (names,e_filename); _files = _files->next; } g_slist_foreach(files,(GFunc)g_free,NULL); g_slist_free(files); switch (archive->type) { case XARCHIVETYPE_TAR: if (archive->full_path) { command = g_strconcat (tar, " -xvf " , archive->escaped_path, #ifdef __FreeBSD__ archive->overwrite ? " " : " -k", #else archive->overwrite ? " --overwrite" : " --keep-old-files", #endif archive->tar_touch ? " --touch" : "", " -C ",archive->extraction_path," ",names->str,NULL); } else { result = xa_extract_tar_without_directories ( "tar -xvf ",archive,names->str); command = NULL; } break; case XARCHIVETYPE_TAR_BZ2: if (archive->full_path) { command = g_strconcat (tar, " -xjvf " , archive->escaped_path, #ifdef __FreeBSD__ archive->overwrite ? " " : " -k", #else archive->overwrite ? " --overwrite" : " --keep-old-files", #endif archive->tar_touch ? " --touch" : "", " -C ",archive->extraction_path," ",names->str,NULL); } else { result = xa_extract_tar_without_directories ( "tar -xjvf ",archive,names->str); command = NULL; } break; case XARCHIVETYPE_TAR_GZ: if (archive->full_path == 1) { command = g_strconcat (tar, " -xzvf " , archive->escaped_path, #ifdef __FreeBSD__ archive->overwrite ? " " : " -k", #else archive->overwrite ? " --overwrite" : " --keep-old-files", #endif archive->tar_touch ? " --touch" : "", " -C ",archive->extraction_path," ",names->str,NULL); } else { result = xa_extract_tar_without_directories ( "tar -xzvf ",archive,names->str); command = NULL; } break; case XARCHIVETYPE_TAR_LZMA: if (archive->full_path == 1) { command = g_strconcat (tar, " --use-compress-program=lzma -xvf " , archive->escaped_path, #ifdef __FreeBSD__ archive->overwrite ? " " : " -k", #else archive->overwrite ? " --overwrite" : " --keep-old-files", #endif archive->tar_touch ? " --touch" : "", " -C ",archive->extraction_path," ",names->str,NULL); } else { result = xa_extract_tar_without_directories ( "tar --use-compress-program=lzma -xvf ",archive,names->str); command = NULL; } break; case XARCHIVETYPE_TAR_LZOP: if (archive->full_path == 1) { command = g_strconcat (tar, " --use-compress-program=lzop -xvf " , archive->escaped_path, #ifdef __FreeBSD__ archive->overwrite ? " " : " -k", #else archive->overwrite ? " --overwrite" : " --keep-old-files", #endif archive->tar_touch ? " --touch" : "", " -C ",archive->extraction_path," ",names->str,NULL); } else { result = xa_extract_tar_without_directories ( "tar --use-compress-program=lzop -xvf ",archive,names->str); command = NULL; } break; case XARCHIVETYPE_LZMA: result = lzma_bzip2_extract(archive,NULL); command = NULL; break; case XARCHIVETYPE_LZOP: result = lzma_bzip2_extract(archive,NULL); command = NULL; break; case XARCHIVETYPE_BZIP2: result = lzma_bzip2_extract(archive,NULL); command = NULL; break; case XARCHIVETYPE_GZIP: result = gzip_extract(archive,NULL); command = NULL; break; default: command = NULL; } if (command != NULL) { g_string_free(names,TRUE); list = g_slist_append(list,command); result = xa_run_command (archive,list); } return result; }