From 1ad4af8dc3ae49fa8a13a6e359a8fdabab36d3f5 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Mon, 13 Jun 2005 12:46:48 +0000 Subject: we can determine if an entry will be stored as a HardLink at prepare() time, so do it... --- usr.sbin/pkg_add/OpenBSD/Ustar.pm | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index a3cd7e6e810..0f4bfc98536 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Ustar.pm,v 1.17 2005/06/13 12:22:37 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.18 2005/06/13 12:46:47 espie Exp $ # # Copyright (c) 2002-2004 Marc Espie # @@ -205,8 +205,11 @@ sub prepare archive => $self, destdir => $self->{destdir} }; - - if (-l $_) { + my $k = $entry->{key}; + if (defined $self->{key}->{$k}) { + $entry->{linkname} = $self->{key}->{$k}; + bless "OpenBSD::Ustar::HardLink", $entry; + } elsif (-l $_) { $entry->{linkname} = readlink("$destdir/$filename"); bless "OpenBSD::Ustar::SoftLink", $entry; } elsif (-d _) { @@ -238,7 +241,8 @@ sub write my $self = shift; my $arc = $self->{archive}; - $self->write_header($arc); + my $header = OpenBSD::Ustar::mkheader($self, $self->type()); + syswrite($arc->{fh}, $header, 512); $self->write_contents($arc); my $k = $self->{key}; if (!defined $arc->{key}->{$k}) { @@ -251,13 +255,6 @@ sub write_contents # only files have anything to write } -sub write_header -{ - my ($self, $arc) = @_; - my $header = OpenBSD::Ustar::mkheader($self, $self->type()); - syswrite($arc->{fh}, $header, 512); -} - sub isDir() { 0 } sub isFile() { 0 } sub isLink() { 0 } @@ -409,17 +406,6 @@ sub create $self->SUPER::set_modes(); } -sub write_header -{ - my ($self, $arc) = @_; - my $k = $self->{key}; - if (defined $arc->{key}->{$k}) { - $self->{linkname} = $arc->{key}->{$k}; - bless "OpenBSD::Ustar::HardLink", $self; - } - $self->SUPER::write_header($arc); -} - sub write_contents { my ($self, $arc) = @_; -- cgit v1.2.3