~ubuntu-branches/ubuntu/feisty/xarchiver/feisty

« back to all changes in this revision

Viewing changes to src/tar.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2006-03-12 09:45:00 UTC
  • Revision ID: james.westby@ubuntu.com-20060312094500-e1m5oxiyro0xfj3a
Tags: upstream-0.3.1
ImportĀ upstreamĀ versionĀ 0.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Xarchiver
 
3
 *
 
4
 *  Copyright (C) 2005 Giuseppe Torelli - Colossus
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include "tar.h"
 
22
 
 
23
extern int output_fd,error_fd,child_pid,child_status;
 
24
 
 
25
void OpenTar ( gboolean mode , gchar *path)
 
26
{
 
27
        gchar *command = g_strconcat ( "tar tfv " , path, NULL );
 
28
        compressor_pid = SpawnAsyncProcess ( command , 1 , 0);
 
29
        g_free ( command );
 
30
        if ( compressor_pid == 0 ) return;
 
31
        char *names[]= {(_("Filename")),(_("Permissions")),(_("Owner/Group")),(_("Size")),(_("Date")),(_("Time"))};
 
32
        GType types[]= {G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UINT,G_TYPE_STRING,G_TYPE_STRING};
 
33
        CreateListStore ( 6, names , (GType *)types );
 
34
        SetIOChannel (output_fd, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,TarOpen, (gpointer) mode );
 
35
        SetIOChannel (error_fd, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,GenError, NULL );
 
36
    WaitExitStatus ( child_pid , NULL );
 
37
}
 
38
 
 
39
static gboolean TarOpen (GIOChannel *ioc, GIOCondition cond, gpointer data)
 
40
{
 
41
        gchar **fields;
 
42
        gchar *filename;
 
43
        gchar *line;
 
44
        if (cond & (G_IO_IN | G_IO_PRI) )
 
45
        {
 
46
                g_io_channel_read_line ( ioc, &line, NULL, NULL, NULL );
 
47
                if (line != NULL && data ) gtk_text_buffer_insert (textbuf, &enditer, line, strlen ( line ) );
 
48
                fields = split_line (line,5);
 
49
                filename = get_last_field (line,6);
 
50
                gtk_list_store_append (liststore, &iter);
 
51
                if ( filename[strlen(filename) - 1] != '/')
 
52
                {
 
53
                        for ( x = 0; x < 5; x++)
 
54
                        {
 
55
                if (x == 2) gtk_list_store_set (liststore, &iter,x+1,atoi(fields[x]),-1);
 
56
                    else gtk_list_store_set (liststore, &iter,x+1,fields[x],-1);
 
57
                        }
 
58
                }
 
59
                gtk_list_store_set (liststore, &iter,0,filename,-1);
 
60
        gtk_progress_bar_pulse ( GTK_PROGRESS_BAR (progressbar) );
 
61
        while (gtk_events_pending() )
 
62
                    gtk_main_iteration();
 
63
                g_strfreev ( fields );
 
64
                g_free (line);
 
65
                return TRUE;
 
66
        }
 
67
        else if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
 
68
        {
 
69
                g_io_channel_shutdown ( ioc,TRUE,NULL );
 
70
                g_io_channel_unref (ioc);
 
71
                return FALSE;
 
72
        }
 
73
}
 
74
 
 
75