20
20
#include "config.h"
22
#include "string_utils.h"
24
void OpenDeb ( XArchive *archive )
24
extern void xa_create_liststore (XArchive *archive,gchar *columns_names[]);
26
void xa_open_deb (XArchive *archive)
26
28
gchar *command = NULL;
27
gchar *archive_no_path = NULL;
30
archive_no_path = g_strrstr (archive->escaped_path,"/");
32
archive->tmp = g_strconcat (" /tmp/",archive_no_path,NULL);
34
/* Let's copy the .deb archive to /tmp */
35
command = g_strconcat ("cp ",archive->escaped_path,archive->tmp,NULL);
36
result = xa_run_command ( command , 0);
41
/* Ok, let's now extract the .deb archive with ar */
43
command = g_strconcat ("ar xv" , archive->tmp, NULL);
44
result = xa_run_command ( command , 0);
46
g_free (archive->tmp);
47
archive->tmp = g_strdup ("/tmp/data.tar.gz");
49
unlink ("/tmp/control.tar.gz");
50
unlink ("/tmp/debian-binary");
51
unlink (archive_no_path);
56
/* Finally, let's show the content in /tmp/data.tar.gz */
57
command = g_strconcat ("tar tfzv /tmp/data.tar.gz", NULL);
31
command = g_strconcat ("ar tv ",archive->escaped_path,NULL);
32
archive->has_properties = archive->can_extract = TRUE;
33
archive->can_add = archive->has_test = archive->has_sfx = FALSE;
58
34
archive->dummy_size = 0;
59
35
archive->nr_of_files = 0;
60
archive->nr_of_dirs = 0;
61
archive->format ="DEB";
62
archive->parse_output = TarOpen;
63
SpawnAsyncProcess ( archive , command , 0, 0);
37
archive->format = "DEB";
38
archive->parse_output = xa_get_ar_line_content;
39
xa_spawn_async_process (archive,command);
66
42
if (archive->child_pid == 0)
69
char *names[]= {(_("Filename")),(_("Permissions")),(_("Symbolic Link")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time"))};
70
GType types[]= {G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_STRING};
71
xa_create_liststore ( 7, names , (GType *)types, archive );
45
char *names[]= {(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date modified")),NULL};
46
GType types[]= {GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT64,G_TYPE_STRING,G_TYPE_POINTER};
47
archive->column_types = g_malloc0(sizeof(types));
48
for (i = 0; i < 7; i++)
49
archive->column_types[i] = types[i];
50
xa_create_liststore (archive,names);
53
void xa_get_ar_line_content (gchar *line, gpointer data)
55
XArchive *archive = data;
59
gint n = 0, a = 0 ,linesize = 0;
61
linesize = strlen(line);
68
for(n=12; n < linesize; ++n)
75
for(++n; n < linesize; ++n)
76
if(line[n] >= '0' && line[n] <= '9')
80
for(; n < linesize; ++n)
86
archive->dummy_size += g_ascii_strtoull(item[2],NULL,0);
90
for(; n < linesize; ++n)
97
for(; n < linesize; ++n)
107
line[linesize-1] = '\0';
109
archive->nr_of_files++;
110
filename = g_strdup(line + n);
111
entry = xa_set_archive_entries_for_each_row (archive,filename,item);
115
gboolean xa_deb_extract(XArchive *archive,GSList *files)
118
GSList *list = NULL,*_files = NULL;
119
GString *names = g_string_new("");
120
gboolean result = FALSE;
125
g_string_prepend (names,(gchar*)_files->data);
126
g_string_prepend_c (names,' ');
127
_files = _files->next;
129
g_slist_foreach(files,(GFunc)g_free,NULL);
132
chdir (archive->extraction_path);
133
command = g_strconcat ("ar x ",archive->escaped_path," ",names->str,NULL);
136
g_string_free(names,FALSE);
137
list = g_slist_append(list,command);
138
result = xa_run_command (archive,list);