Permalink
Browse files

Add support for parsing TOC files from tar/directory dumps.

  • Loading branch information...
adunstan committed Mar 29, 2012
1 parent d4399bc commit b24a44e0fc9e3c75d463959c28ced39c1964cb1e
Showing with 20 additions and 5 deletions.
  1. +20 −5 dumpToc.pl
View
@@ -17,11 +17,12 @@
use Getopt::Long;
use File::Path qw(make_path);
-my ($format,$destdir,$dumpfile,$help);
+my ($format,$destdir,$dumpfile,$help, $tocfile);
GetOptions ("format=s" => \$format,
"destdir=s" => \$destdir,
"dumpfile=s" => \$dumpfile,
+ "tocfile=s" => \$tocfile,
"help" => \$help)
|| die "Bad options";
@@ -39,16 +40,23 @@
my $runscript;
my %fnames;
+if ($tocfile && $dumpfile)
+{
+ die "tocfile and dumpfile options are mutually exclusive";
+}
if (@ARGV)
{
die "dumpfile already given" if $dumpfile;
$dumpfile = shift(@ARGV);
}
-if ($dumpfile)
+my $src = $dumpfile;
+$src ||= $tocfile;
+
+if ($src)
{
- open($inh,$dumpfile) || die "opening $dumpfile: $!";
+ open($inh,$src) || die "opening $src: $!";
}
else
{
@@ -193,7 +201,14 @@ sub readTocEntry
push @$deps, $dep;
}
- push @$toce, {extra_offset => ReadOffset()};
+ if ($globs{format} eq 'Custom')
+ {
+ push @$toce, {extra_offset => ReadOffset()};
+ }
+ else
+ {
+ push @$toce, {file_name => ReadStr()};
+ }
return $toce;
@@ -234,6 +249,6 @@ sub read_data
sub help
{
- print STDERR "$0: [ --help | --format=format | --destdir=destdir ] [ [--dumpfile=]dumpfile ]\n";
+ print STDERR "$0: [ --help | --format=format | --destdir=destdir ] [ [--dumpfile=|--tocfile=]dump_or_toc_file ]\n";
exit 0;
}

0 comments on commit b24a44e

Please sign in to comment.