27
void OpenGzip ( XArchive *archive )
23
extern delete_func delete [XARCHIVETYPE_COUNT];
24
extern add_func add [XARCHIVETYPE_COUNT];
25
extern extract_func extract [XARCHIVETYPE_COUNT];
27
/* GString here is used only to respect the prototype of the
28
* extract function so to make life easier to the coder :)*/
30
void xa_open_gzip (XArchive *archive)
31
if ( g_str_has_suffix ( archive->escaped_path , ".tar.gz") || g_str_has_suffix ( archive->escaped_path , ".tgz") )
35
if (g_str_has_suffix (archive->escaped_path,".tar.gz") || g_str_has_suffix (archive->escaped_path,".tgz"))
35
tar = g_find_program_in_path ("gtar");
37
tar = g_strdup ("tar");
37
archive->type = XARCHIVETYPE_TAR_GZ;
38
archive->delete = delete[archive->type];
39
archive->add = add[archive->type];
40
archive->extract = extract[archive->type];
39
42
command = g_strconcat (tar, " tzvf " , archive->escaped_path, NULL );
43
archive->has_properties = archive->can_add = archive->can_extract = TRUE;
44
archive->has_test = archive->has_sfx = FALSE;
40
45
archive->dummy_size = 0;
41
46
archive->nr_of_files = 0;
42
archive->nr_of_dirs = 0;
43
47
archive->format ="TAR.GZIP";
44
archive->parse_output = TarOpen;
46
SpawnAsyncProcess ( archive , command , 0, 0);
51
if ( archive->child_pid == 0 )
54
char *names[]= {(_("Filename")),(_("Permissions")),(_("Symbolic Link")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time"))};
55
GType types[]= {G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_STRING};
56
xa_create_liststore ( 7, names , (GType *)types, archive );
57
archive->type = XARCHIVETYPE_TAR_GZ;
61
extract_window = xa_create_extract_dialog ( 0 , archive);
62
command = xa_parse_extract_dialog_options ( archive , extract_window, NULL );
63
gtk_widget_destroy ( extract_window->dialog1 );
64
g_free (extract_window);
49
archive->parse_output = xa_get_tar_line_content;
50
xa_spawn_async_process (archive,command);
53
if (archive->child_pid == 0)
56
GType types[]= {GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_POINTER};
57
archive->column_types = g_malloc0(sizeof(types));
58
for (i = 0; i < 9; i++)
59
archive->column_types[i] = types[i];
61
char *names[]= {(_("Points to")),(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time")),NULL};
62
xa_create_liststore (archive,names);
66
archive->can_add = archive->has_test = archive->has_sfx = FALSE;
67
archive->has_properties = archive->can_extract = TRUE;
69
archive->parse_output = xa_get_gzip_line_content;
70
archive->nr_of_files = 1;
71
archive->format = "GZIP";
73
GType types[]= {GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_POINTER};
74
archive->column_types = g_malloc0(sizeof(types));
75
for (i = 0; i < 6; i++)
76
archive->column_types[i] = types[i];
78
char *names[]= {(_("Compressed")),(_("Size")),(_("Ratio"))};
79
xa_create_liststore (archive,names);
81
command = g_strconcat ("gzip -l ",archive->escaped_path,NULL);
82
xa_spawn_async_process (archive,command);
85
if (archive->child_pid == 0)
90
void xa_get_gzip_line_content (gchar *line, gpointer data)
92
XArchive *archive = data;
97
gint n = 0, a = 0 ,linesize = 0;
99
linesize = strlen(line);
104
for(n=0; n < linesize && line[n] == ' '; n++);
106
for(; n < linesize && line[n] != ' '; n++);
112
for(; n < linesize && line[n] == ' '; n++);
114
for(; n < linesize && line[n] != ' '; n++);
117
archive->dummy_size += g_ascii_strtoull(item[1],NULL,0);
121
for(; n < linesize && line[n] == ' '; n++);
123
for(; n < linesize && line[n] != ' '; n++);
128
line[linesize-1] = '\0';
131
basename = g_path_get_basename(filename);
132
if (basename == NULL)
133
basename = g_strdup(filename);
135
entry = xa_set_archive_entries_for_each_row (archive,basename,item);
139
gboolean gzip_extract(XArchive *archive,GSList *dummy)
141
gchar *command = NULL,*filename = NULL,*dot,*filename_noext;
144
filename = xa_remove_path_from_archive_name(archive->escaped_path);
145
dot = strrchr(filename,'.');
148
filename_noext = g_strndup(filename,(dot - filename));
152
filename_noext = filename;
154
command = g_strconcat("sh -c \"gunzip -cd ",archive->escaped_path," > ",archive->extraction_path,"/",filename_noext,"\"",NULL);
155
list = g_slist_append(list,command);
156
return xa_run_command (archive,list);