diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-06-20 13:27:39 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-06-20 13:27:39 +0000 |
commit | 1a5d8bc25c022351355389bd2f3e1b52c34b5bee (patch) | |
tree | 701174891d5c2e525cc58ae82b2a4d7daa8725f5 | |
parent | d1e87bd1161081c050d5072e0919c7ba53d40ff1 (diff) |
flesh out the destdir() working. Provide a convenience close() method.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Ustar.pm | 28 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pod/OpenBSD::Ustar.pod | 11 |
2 files changed, 35 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index 2d7ce0bd46f..d86954a4923 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.26 2005/06/18 13:17:11 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.27 2005/06/20 13:27:37 espie Exp $ # # Copyright (c) 2002-2004 Marc Espie <espie@openbsd.org> # @@ -267,6 +267,30 @@ sub pad print $fh "\0"x1024; } +sub close +{ + my $self = shift; + if (defined $self->{padout}) { + $self->pad(); + } + close($self->{fh}); +} + +sub destdir +{ + my $self = shift; + if (@_ > 0) { + $self->{destdir} = shift; + } else { + return $self->{destdir}; + } +} + +sub fh +{ + return $_[0]->{fh}; +} + package OpenBSD::Ustar::Object; sub set_modes { @@ -289,6 +313,7 @@ sub write my $arc = $self->{archive}; my $out = $arc->{fh}; + $arc->{padout} = 1; my $header = OpenBSD::Ustar::mkheader($self, $self->type()); print $out $header; $self->write_contents($arc); @@ -318,6 +343,7 @@ sub copy my ($self, $wrarc) = @_; my $out = $wrarc->{fh}; $self->resolve_links($wrarc); + $wrarc->{padout} = 1; my $header = OpenBSD::Ustar::mkheader($self, $self->type()); print $out $header; diff --git a/usr.sbin/pkg_add/pod/OpenBSD::Ustar.pod b/usr.sbin/pkg_add/pod/OpenBSD::Ustar.pod index 136394a6637..7b9f45bc3f5 100644 --- a/usr.sbin/pkg_add/pod/OpenBSD::Ustar.pod +++ b/usr.sbin/pkg_add/pod/OpenBSD::Ustar.pod @@ -1,4 +1,4 @@ -$OpenBSD: OpenBSD::Ustar.pod,v 1.6 2005/06/13 18:38:59 espie Exp $ +$OpenBSD: OpenBSD::Ustar.pod,v 1.7 2005/06/20 13:27:38 espie Exp $ =head1 NAME @@ -91,6 +91,10 @@ hold any resources and doesn't need any specific clean-up. However, client code is responsible for closing the underlying filehandle and terminating any associated pipe process. +A convenience method C<close> is provided that can be used to finish reading +or writing to an archive, providing adequate padding and closing the +associated filehandle. + An object C<$o> returned through C<next> or through C<prepare> holds all the characteristics of the archive header: @@ -160,8 +164,9 @@ conforms to the USTAR format usual behavior. In addition, client code may define C<$o-E<gt>{cwd}> in a way similar to C<tar(1)>'s C<-C> option to affect the creation of hard links. -All creation commands happen relative to the C<$destdir> that was used -for creating the C<$arc> C<OpenBSD::Ustar> object. +All creation commands happen relative to the current destdir of +the C<$arc> C<OpenBSD::Ustar> object. This is set at creation, and can +later be changed through C<$arc-E<gt>destdir($value)>. During writing, hard link status is determined according to already written archive entries: a name that references a file which has already been written |