.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Archive::Tar::File 3perl" .TH Archive::Tar::File 3perl 2024-02-11 "perl v5.38.2" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Archive::Tar::File \- a subclass for in\-memory extracted file from Archive::Tar .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& my @items = $tar\->get_files; \& \& print $_\->name, \*(Aq \*(Aq, $_\->size, "\en" for @items; \& \& print $object\->get_content; \& $object\->replace_content(\*(Aqnew content\*(Aq); \& \& $object\->rename( \*(Aqnew/full/path/to/file.c\*(Aq ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Archive::Tar::Files provides a neat little object layer for in-memory extracted files. It's mostly used internally in Archive::Tar to tidy up the code, but there's no reason users shouldn't use this API as well. .SS Accessors .IX Subsection "Accessors" A lot of the methods in this package are accessors to the various fields in the tar header: .IP name 4 .IX Item "name" The file's name .IP mode 4 .IX Item "mode" The file's mode .IP uid 4 .IX Item "uid" The user id owning the file .IP gid 4 .IX Item "gid" The group id owning the file .IP size 4 .IX Item "size" File size in bytes .IP mtime 4 .IX Item "mtime" Modification time. Adjusted to mac-time on MacOS if required .IP chksum 4 .IX Item "chksum" Checksum field for the tar header .IP type 4 .IX Item "type" File type \-\- numeric, but comparable to exported constants \-\- see Archive::Tar's documentation .IP linkname 4 .IX Item "linkname" If the file is a symlink, the file it's pointing to .IP magic 4 .IX Item "magic" Tar magic string \-\- not useful for most users .IP version 4 .IX Item "version" Tar version string \-\- not useful for most users .IP uname 4 .IX Item "uname" The user name that owns the file .IP gname 4 .IX Item "gname" The group name that owns the file .IP devmajor 4 .IX Item "devmajor" Device major number in case of a special file .IP devminor 4 .IX Item "devminor" Device minor number in case of a special file .IP prefix 4 .IX Item "prefix" Any directory to prefix to the extraction path, if any .IP raw 4 .IX Item "raw" Raw tar header \-\- not useful for most users .SH Methods .IX Header "Methods" .ie n .SS "Archive::Tar::File\->new( file => $path )" .el .SS "Archive::Tar::File\->new( file => \f(CW$path\fP )" .IX Subsection "Archive::Tar::File->new( file => $path )" Returns a new Archive::Tar::File object from an existing file. .PP Returns undef on failure. .ie n .SS "Archive::Tar::File\->new( data => $path, $data, $opt )" .el .SS "Archive::Tar::File\->new( data => \f(CW$path\fP, \f(CW$data\fP, \f(CW$opt\fP )" .IX Subsection "Archive::Tar::File->new( data => $path, $data, $opt )" Returns a new Archive::Tar::File object from data. .PP \&\f(CW$path\fR defines the file name (which need not exist), \f(CW$data\fR the file contents, and \f(CW$opt\fR is a reference to a hash of attributes which may be used to override the default attributes (fields in the tar header), which are described above in the Accessors section. .PP Returns undef on failure. .ie n .SS "Archive::Tar::File\->new( chunk => $chunk )" .el .SS "Archive::Tar::File\->new( chunk => \f(CW$chunk\fP )" .IX Subsection "Archive::Tar::File->new( chunk => $chunk )" Returns a new Archive::Tar::File object from a raw 512\-byte tar archive chunk. .PP Returns undef on failure. .ie n .SS "$bool = $file\->extract( [ $alternative_name ] )" .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->extract( [ \f(CW$alternative_name\fP ] )" .IX Subsection "$bool = $file->extract( [ $alternative_name ] )" Extract this object, optionally to an alternative name. .PP See \f(CW\*(C`Archive::Tar\->extract_file\*(C'\fR for details. .PP Returns true on success and false on failure. .ie n .SS "$path = $file\->full_path" .el .SS "\f(CW$path\fP = \f(CW$file\fP\->full_path" .IX Subsection "$path = $file->full_path" Returns the full path from the tar header; this is basically a concatenation of the \f(CW\*(C`prefix\*(C'\fR and \f(CW\*(C`name\*(C'\fR fields. .ie n .SS "$bool = $file\->validate" .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->validate" .IX Subsection "$bool = $file->validate" Done by Archive::Tar internally when reading the tar file: validate the header against the checksum to ensure integer tar file. .PP Returns true on success, false on failure .ie n .SS "$bool = $file\->has_content" .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->has_content" .IX Subsection "$bool = $file->has_content" Returns a boolean to indicate whether the current object has content. Some special files like directories and so on never will have any content. This method is mainly to make sure you don't get warnings for using uninitialized values when looking at an object's content. .ie n .SS "$content = $file\->get_content" .el .SS "\f(CW$content\fP = \f(CW$file\fP\->get_content" .IX Subsection "$content = $file->get_content" Returns the current content for the in-memory file .ie n .SS "$cref = $file\->get_content_by_ref" .el .SS "\f(CW$cref\fP = \f(CW$file\fP\->get_content_by_ref" .IX Subsection "$cref = $file->get_content_by_ref" Returns the current content for the in-memory file as a scalar reference. Normal users won't need this, but it will save memory if you are dealing with very large data files in your tar archive, since it will pass the contents by reference, rather than make a copy of it first. .ie n .SS "$bool = $file\->replace_content( $content )" .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->replace_content( \f(CW$content\fP )" .IX Subsection "$bool = $file->replace_content( $content )" Replace the current content of the file with the new content. This only affects the in-memory archive, not the on-disk version until you write it. .PP Returns true on success, false on failure. .ie n .SS "$bool = $file\->rename( $new_name )" .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->rename( \f(CW$new_name\fP )" .IX Subsection "$bool = $file->rename( $new_name )" Rename the current file to \f(CW$new_name\fR. .PP Note that you must specify a Unix path for \f(CW$new_name\fR, since per tar standard, all files in the archive must be Unix paths. .PP Returns true on success and false on failure. .ie n .SS "$bool = $file\->chmod $mode)" .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->chmod \f(CW$mode\fP)" .IX Subsection "$bool = $file->chmod $mode)" Change mode of \f(CW$file\fR to \f(CW$mode\fR. The mode can be a string or a number which is interpreted as octal whether or not a leading 0 is given. .PP Returns true on success and false on failure. .ie n .SS "$bool = $file\->chown( $user [, $group])" .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->chown( \f(CW$user\fP [, \f(CW$group\fP])" .IX Subsection "$bool = $file->chown( $user [, $group])" Change owner of \f(CW$file\fR to \f(CW$user\fR. If a \f(CW$group\fR is given that is changed as well. You can also pass a single parameter with a colon separating the use and group as in 'root:wheel'. .PP Returns true on success and false on failure. .SH "Convenience methods" .IX Header "Convenience methods" To quickly check the type of a \f(CW\*(C`Archive::Tar::File\*(C'\fR object, you can use the following methods: .ie n .IP $file\->is_file 4 .el .IP \f(CW$file\fR\->is_file 4 .IX Item "$file->is_file" Returns true if the file is of type \f(CW\*(C`file\*(C'\fR .ie n .IP $file\->is_dir 4 .el .IP \f(CW$file\fR\->is_dir 4 .IX Item "$file->is_dir" Returns true if the file is of type \f(CW\*(C`dir\*(C'\fR .ie n .IP $file\->is_hardlink 4 .el .IP \f(CW$file\fR\->is_hardlink 4 .IX Item "$file->is_hardlink" Returns true if the file is of type \f(CW\*(C`hardlink\*(C'\fR .ie n .IP $file\->is_symlink 4 .el .IP \f(CW$file\fR\->is_symlink 4 .IX Item "$file->is_symlink" Returns true if the file is of type \f(CW\*(C`symlink\*(C'\fR .ie n .IP $file\->is_chardev 4 .el .IP \f(CW$file\fR\->is_chardev 4 .IX Item "$file->is_chardev" Returns true if the file is of type \f(CW\*(C`chardev\*(C'\fR .ie n .IP $file\->is_blockdev 4 .el .IP \f(CW$file\fR\->is_blockdev 4 .IX Item "$file->is_blockdev" Returns true if the file is of type \f(CW\*(C`blockdev\*(C'\fR .ie n .IP $file\->is_fifo 4 .el .IP \f(CW$file\fR\->is_fifo 4 .IX Item "$file->is_fifo" Returns true if the file is of type \f(CW\*(C`fifo\*(C'\fR .ie n .IP $file\->is_socket 4 .el .IP \f(CW$file\fR\->is_socket 4 .IX Item "$file->is_socket" Returns true if the file is of type \f(CW\*(C`socket\*(C'\fR .ie n .IP $file\->is_longlink 4 .el .IP \f(CW$file\fR\->is_longlink 4 .IX Item "$file->is_longlink" Returns true if the file is of type \f(CW\*(C`LongLink\*(C'\fR. Should not happen after a successful \f(CW\*(C`read\*(C'\fR. .ie n .IP $file\->is_label 4 .el .IP \f(CW$file\fR\->is_label 4 .IX Item "$file->is_label" Returns true if the file is of type \f(CW\*(C`Label\*(C'\fR. Should not happen after a successful \f(CW\*(C`read\*(C'\fR. .ie n .IP $file\->is_unknown 4 .el .IP \f(CW$file\fR\->is_unknown 4 .IX Item "$file->is_unknown" Returns true if the file type is \f(CW\*(C`unknown\*(C'\fR