Subject: | File type constants are not documented |
The file type constants in Archive::Tar::Constants are not documented, despite a reference in the Archive::Tar::File POD to their being an explanation in Archive::Tar. Further, 'type' is not mentioned as one of the fields which may be passed to Archive::Tar->add_data(). The attached patch corrects this.
Also, a function for generating the appropriate type constants from the mode bits would be useful. Something like this:
# file_type_tar MODE
# Return the tar file type for a file with the given MODE bits.
sub file_type_tar ($) {
my $m = shift;
if (S_ISDIR($m)) {
return Archive::Tar::Constant::DIR;
} elsif (S_ISREG($m)) {
return Archive::Tar::Constant::FILE;
} elsif (S_ISLNK($m)) {
return Archive::Tar::Constant::SYMLINK;
} elsif (S_ISFIFO($m)) {
return Archive::Tar::Constant::FIFO;
} elsif (S_ISCHR($m)) {
return Archive::Tar::Constant::CHARDEV;
} elsif (S_ISBLK($m)) {
return Archive::Tar::Constant::BLOCKDEV;
}
}
--- Tar.pm.orig Fri Nov 18 18:10:56 2005
+++ Tar.pm Fri Nov 18 18:13:43 2005
@@ -1101,9 +1101,45 @@
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.