aboutsummaryrefslogtreecommitdiffstats
path: root/Packdrakeng.pm
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2004-12-20 12:25:12 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2004-12-20 12:25:12 +0000
commitcde5d14ee8dcc01db2d162cac51dd61c17c79673 (patch)
tree6ee2a121d9bda20358e349d0d3b3ab12ef59270f /Packdrakeng.pm
parentcb79b50bdae11bfb9cbfb0b3ebeaf7acfba5d1d4 (diff)
downloadrpmtools-cde5d14ee8dcc01db2d162cac51dd61c17c79673.tar
rpmtools-cde5d14ee8dcc01db2d162cac51dd61c17c79673.tar.gz
rpmtools-cde5d14ee8dcc01db2d162cac51dd61c17c79673.tar.bz2
rpmtools-cde5d14ee8dcc01db2d162cac51dd61c17c79673.tar.xz
rpmtools-cde5d14ee8dcc01db2d162cac51dd61c17c79673.zip
- add infofile() function
- more doc
Diffstat (limited to 'Packdrakeng.pm')
-rw-r--r--Packdrakeng.pm49
1 files changed, 43 insertions, 6 deletions
diff --git a/Packdrakeng.pm b/Packdrakeng.pm
index 5fa03cf..6e13d65 100644
--- a/Packdrakeng.pm
+++ b/Packdrakeng.pm
@@ -571,8 +571,22 @@ sub getcontent {
return([ keys(%{$pack->{dir}})], [ keys(%{$pack->{files}}) ], [ keys(%{$pack->{'symlink'}}) ]);
}
+sub infofile {
+ my ($pack, $file) = @_;
+ if (defined($pack->{files}{$file})) {
+ return ('f', $pack->{files}{$file}{size});
+ } elsif (defined($pack->{'symlink'}{$file})) {
+ return ('l', $pack->{'symlink'}{$file});
+ } elsif (defined($pack->{dir}{$file})) {
+ return ('d', undef);
+ } else {
+ return(undef, undef);
+ }
+}
+
sub list {
- my ($pack) = @_;
+ my ($pack, $handle) = @_;
+ $handle ||= *STDOUT;
foreach my $file (keys %{$pack->{dir}}) {
printf "d %13c %s\n", ' ', $file;
}
@@ -590,19 +604,20 @@ sub list {
# Print toc info
sub dumptoc {
- my ($pack) = @_;
- foreach my $file (keys %{$pack->{dir}}) {
- printf "d %13c %s\n", ' ', $file;
+ my ($pack, $handle) = @_;
+ $handle ||= *STDOUT;
+ foreach my $file (keys %{$pack->{dir}}) {
+ printf $handle "d %13c %s\n", ' ', $file;
}
foreach my $file (keys %{$pack->{'symlink'}}) {
- printf "l %13c %s -> %s\n", ' ', $file, $pack->{'symlink'}{$file};
+ printf $handle "l %13c %s -> %s\n", ' ', $file, $pack->{'symlink'}{$file};
}
foreach my $file (sort {
$pack->{files}{$a}{coff} == $pack->{files}{$b}{coff} ?
$pack->{files}{$a}{off} <=> $pack->{files}{$b}{off} :
$pack->{files}{$a}{coff} <=> $pack->{files}{$b}{coff}
} keys %{$pack->{files}}) {
- printf "f %d %d %d %d %s\n", $pack->{files}{$file}{size}, $pack->{files}{$file}{off}, $pack->{files}{$file}{csize}, $pack->{files}{$file}{coff}, $file;
+ printf $handle "f %d %d %d %d %s\n", $pack->{files}{$file}{size}, $pack->{files}{$file}{off}, $pack->{files}{$file}{csize}, $pack->{files}{$file}{coff}, $file;
}
}
@@ -796,6 +811,28 @@ normal file.
Extract @files from the archive into $destdir prefix.
+=item B<Packdrakeng->getcontent()>
+
+Return 3 arrayref about found files into archive, respectively directory list,
+files list and symlink list.
+
+=item B<Packdrakeng->infofile($file)>
+
+Return the type and information about a file into the archive.
+
+- return 'f' and the the size of the file for a plain file
+- return 'l' and the point file for a link
+- return 'd' and undef for a directory
+- return undef if the file can't be found into archive.
+
+=item B<Packdrakeng->infofile($handle)>
+
+Print to $handle (STDOUT if not specified) the content of the archive.
+
+=item B<Packdrakeng->dumptoc($handle)>
+
+Print to $handle (STDOUT if not specified) the table of content of the archive.
+
=head1 AUTHOR
Olivier Thauvin <nanardon@mandrake.org>