From b41b30411afffc3c928687f4da1b5e4ac9d11fb0 Mon Sep 17 00:00:00 2001 From: rjray Date: Tue, 1 Aug 2000 07:59:47 +0000 Subject: [PATCH] Added the filenames() method and documented it. This method re-assembles the file fully-qualified names from the three header tags. CVS patchset: 3995 CVS date: 2000/08/01 07:59:47 --- Perl-RPM/RPM/Header.pm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/Perl-RPM/RPM/Header.pm b/Perl-RPM/RPM/Header.pm index 461e756..3312271 100644 --- a/Perl-RPM/RPM/Header.pm +++ b/Perl-RPM/RPM/Header.pm @@ -5,7 +5,7 @@ # ############################################################################### # -# $Id: Header.pm,v 1.6 2000/06/22 08:42:00 rjray Exp $ +# $Id: Header.pm,v 1.7 2000/08/01 07:59:47 rjray Exp $ # # Description: The RPM::Header class provides access to the RPM Header # structure as a tied hash, allowing direct access to the @@ -35,7 +35,7 @@ use RPM::Error; use RPM::Constants ':rpmerr'; $VERSION = $RPM::VERSION; -$revision = do { my @r=(q$Revision: 1.6 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; +$revision = do { my @r=(q$Revision: 1.7 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; 1; @@ -48,6 +48,47 @@ sub new return (tied %hash); } +############################################################################### +# +# Sub Name: filenames +# +# Description: Glue together the contents of BASENAMES, DIRNAMES and +# DIRINDEXES to create a single list of fully-qualified +# filenames +# +# Arguments: NAME IN/OUT TYPE DESCRIPTION +# $self in ref Object of this class +# +# Globals: None. +# +# Environment: None. +# +# Returns: Success: listref +# Failure: undef +# +############################################################################### +sub filenames +{ + my $self = shift; + + # Each of these three fetches will have already triggered rpm_error, were + # there any problems. + my $base = $self->{BASENAMES} || return undef; + my $dirs = $self->{DIRNAMES} || return undef; + my $idxs = $self->{DIRINDEXES} || return undef; + + unless (@$base == @$idxs) + { + rpm_error(RPMERR_INTERNAL, + "Mis-matched elements lists for BASENAMES and DIRINDEXES"); + return undef; + } + + # The value from DIRNAMES already has the trailing separator + [ map { "$dirs->[$idxs->[$_]]$base->[$_]" } (0 .. $#$base) ]; +} + + __END__ =head1 NAME @@ -115,6 +156,15 @@ hash reference, it can be used to call these methods via: =over +=item filenames + +The B system attempts to save space by splitting up the file paths into +the leafs (stored by the tag C), the directories (stored under +C) and indexes into the list of directories (stored under +C). As a convenience, this method re-assembles the list of +filenames and returns it as a list reference. If an error occurs, C +will be returned after C has been called. + =item is_source Returns true (1) or false (0), depending on whether the package the header -- 2.7.4