summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-09-13 21:20:02 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-09-13 21:20:02 +0000
commit1c0cfe866c6d27bcf2266c00206273572ea38d15 (patch)
treee9083cbf133ab55fa82172be1f9e63472e1d67cb /usr.sbin/pkg_add
parenta4548c7ca86148843ac7b1563a964d899470605c (diff)
more Package/FatPackage common code: separate the proxy 'next' into two
parts: the one that gets (and renames) files from the archive (getNext) that depends on Package/FatPackage, and the one that handles opening/ reopening/caching archives (true next);
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageLocator.pm45
1 files changed, 21 insertions, 24 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
index fd1e8ef960d..ba47be960c8 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageLocator.pm,v 1.30 2005/09/13 21:08:14 espie Exp $
+# $OpenBSD: PackageLocator.pm,v 1.31 2005/09/13 21:20:01 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -539,47 +539,44 @@ sub next
}
}
if (!$self->{_unput}) {
- my $e = $self->{_archive}->next();
- $self->{_current} = $e;
+ $self->{_current} = $self->getNext();
}
$self->{_unput} = 0;
return $self->{_current};
}
sub unput
-{ my $self = shift;
+{
+ my $self = shift;
$self->{_unput} = 1;
}
+sub getNext
+{
+ my $self = shift;
+
+ return $self->{_archive}->next();
+}
+
package OpenBSD::FatPackageLocation;
our @ISA=qw(OpenBSD::PackageLocation);
-# proxy for archive operations
-sub next
+sub getNext
{
my $self = shift;
- if (!defined $self->{fh}) {
- if (!$self->reopen()) {
- return undef;
+ my $e = $self->SUPER::getNext();
+ if ($e->{name} =~ m/^(.*?)\/(.*)$/) {
+ my ($beg, $name) = ($1, $2);
+ if (index($beg, $self->{filter}) == -1) {
+ return $self->next();
}
- }
- if (!$self->{_unput}) {
- my $e = $self->{_archive}->next();
- if ($e->{name} =~ m/^(.*?)\/(.*)$/) {
- my ($beg, $name) = ($1, $2);
- if (index($beg, $self->{filter}) == -1) {
- return $self->next();
- }
- $e->{name} = $name;
- if ($e->isHardLink()) {
- $e->{linkname} =~ s/^(.*?)\///;
- }
+ $e->{name} = $name;
+ if ($e->isHardLink()) {
+ $e->{linkname} =~ s/^(.*?)\///;
}
- $self->{_current} = $e;
}
- $self->{_unput} = 0;
- return $self->{_current};
+ return $e;
}
package OpenBSD::PackageRepositoryList;