$DEBUG = 0;
$WARN = 1;
$FOLLOW_SYMLINK = 0;
-$VERSION = "1.26_01";
+$VERSION = "1.28";
$CHOWN = 1;
$CHMOD = 1;
$DO_NOT_USE_PREFIX = 0;
Archive::Tar will warn if you try to pass a compressed file if
IO::Zlib is not available and simply return.
+Note that you can currently B<not> pass a C<gzip> compressed
+filehandle, which is not opened with C<IO::Zlib>, nor a string
+containing the full archive information (either compressed or
+uncompressed). These are worth while features, but not currently
+implemented. See the C<TODO> section.
+
The third argument can be a hash reference with options. Note that
all options are case-sensitive.
content C<$data>. Specific properties can be set using C<$opthashref>.
The following list of properties is supported: name, size, mtime
(last modified date), mode, uid, gid, linkname, uname, gname,
-devmajor, devminor, prefix. (On MacOS, the file's path and
+devmajor, devminor, prefix, type. (On MacOS, the file's path and
modification times are converted to Unix equivalents.)
+Valid values for the file type are the following constants defined in
+Archive::Tar::Constants:
+
+=over 4
+
+=item FILE
+
+Regular file.
+
+=item HARDLINK
+
+=item SYMLINK
+
+Hard and symbolic ("soft") links; linkname should specify target.
+
+=item CHARDEV
+
+=item BLOCKDEV
+
+Character and block devices. devmajor and devminor should specify the major
+and minor device numbers.
+
+=item DIR
+
+Directory.
+
+=item FIFO
+
+FIFO (named pipe).
+
+=item SOCKET
+
+Socket.
+
+=back
+
Returns the C<Archive::Tar::File> object that was just added, or
C<undef> on failure.
If C<list_archive()> is passed an array reference as its third
argument it returns a list of hash references containing the requested
properties of each file. The following list of properties is
-supported: name, size, mtime (last modified date), mode, uid, gid,
-linkname, uname, gname, devmajor, devminor, prefix.
+supported: full_path, name, size, mtime (last modified date), mode,
+uid, gid, linkname, uname, gname, devmajor, devminor, prefix.
+
+See C<Archive::Tar::File> for details about supported properties.
Passing an array reference containing only one element, 'name', is
special cased to return a list of names rather than a list of hash
Currently I don't know of any portable pure perl way to do this.
Suggestions welcome.
+=item Allow archives to be passed in as string
+
+Currently, we only allow opened filehandles or filenames, but
+not strings. The internals would need some reworking to facilitate
+stringified archives.
+
+=item Facilitate processing an opened filehandle of a compressed archive
+
+Currently, we only support this if the filehandle is an IO::Zlib object.
+Environments, like apache, will present you with an opened filehandle
+to an uploaded file, which might be a compressed archive.
+
=back
=head1 AUTHOR
] . $/;
}
+
+
+
+=head1 NAME
+
+ptardiff - program that diffs an extracted archive against an unextracted one
+
+=head1 DESCRIPTION
+
+ ptardiff is a small program that diffs an extracted archive
+ against an unextracted one, using the perl module Archive::Tar.
+
+ This effectively lets you view changes made to an archives contents.
+
+ Provide the progam with an ARCHIVE_FILE and it will look up all
+ the files with in the archive, scan the current working directory
+ for a file with the name and diff it against the contents of the
+ archive.
+
+=head1 SYNOPSIS
+
+ ptardiff ARCHIVE_FILE
+ ptardiff -h
+
+ $ tar -xzf Acme-Buffy-1.3.tar.gz
+ $ vi Acme-Buffy-1.3/README
+ [...]
+ $ ptardiff Acme-Buffy-1.3.tar.gz > README.patch
+
+
+=head1 OPTIONS
+
+ h Prints this help message
+
+=head1 SEE ALSO
+
+tar(1), L<Archive::Tar>.
+
+=cut
### remove the file
unless( $NO_UNLINK ) { 1 while unlink $out }
}
+
+### bug #14922
+### There's a bug in Archive::Tar that causes a file like: foo/foo.txt
+### to be stored in the tar file as: foo/.txt
+### XXX could not be reproduced in 1.26 -- leave test to be sure
+{ my $dir = $$ . '/';
+ my $file = $$ . '.txt';
+ my $out = $$ . '.tar';
+
+ ### first create the file
+ { my $tar = $Class->new;
+
+ isa_ok( $tar, $Class );
+ ok( $tar->add_data( $dir.$file => $$ ),
+ " Added long file" );
+
+ ok( $tar->write($out), " File written to $out" );
+ }
+
+ ### then read it back in
+ { my $tar = $Class->new;
+ isa_ok( $tar, $Class );
+ ok( $tar->read( $out ), " Read in $out again" );
+
+ my @files = $tar->get_files;
+ is( scalar(@files), 1, " Only 1 entry found" );
+
+ my $entry = shift @files;
+ ok( $entry->is_file, " Entry is a file" );
+ is( $entry->full_path, $dir.$file,
+ " With the proper name" );
+ }
+
+ ### remove the file
+ unless( $NO_UNLINK ) { 1 while unlink $out }
+}
+
+
+
+