ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / modules / extfs / tar
1 #!/usr/bin/perl
2
3 sub list {
4         ($filename) = @_;
5         $uid = `id -u`;
6         $gid = `id -g`;
7         chomp($uid);
8         chomp($gid);
9         open(TARLIST, "tar tvf $filename|");
10         while(<TARLIST>) {
11                 s/\s+/ /g;
12                 ($perms, $usergroup, $size, $date, $time, $name) = split;
13                 
14                 # convert tar fmt dates/times to our date/time format
15                 ($year, $month, $day) = split(/-/, $date);
16                 ($hours, $mins, $secs) = split(/-/, $time);
17                 #printf "-rw-------   1 %-8s %-8s %8s %02d-%02d-%02d %02d:%02d %s\n", $uid, $gid, $size, $day, $month, ($year%100), $hours, $mins, $name;
18                 printf "%s   1 %-8s %-8s %8s %02d-%02d-%02d %02d:%02d %s\n", $perms, $uid, $gid, $size, $day, $month, ($year%100), $hours, $mins, $name;
19         }
20 }
21
22 sub copyout {
23         ($archive, $stored, $local) = @_;
24         $result = system("tar xOf $archive $stored > $local");
25         exit $result
26 }
27
28 $command = $ARGV[0];
29
30 if($command eq "list") {
31         list($ARGV[1]);
32 } elsif($command eq "copyout") {
33         copyout($ARGV[1], $ARGV[2], $ARGV[3]);
34 }