man > Archive::Tar::File

πŸ“– NAME

Archive::Tar::File - a subclass for in-memory extracted file from Archive::Tar

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ“‚ Create from fileArchive::Tar::File->new( file => $path )🧩 Create a new object from an existing file
πŸ“ Create from dataArchive::Tar::File->new( data => $path, $data, $opt )🧩 Create a new object from in-memory data
πŸ“¦ Create from raw chunkArchive::Tar::File->new( chunk => $chunk )🧩 Create a new object from a raw 512-byte tar header chunk
πŸ“€ Extract file$file->extract( [ $alternative_name ] )πŸ“¦ Extract the file to disk
πŸ“– Get content$file->get_contentπŸ“„ Return the file's content as a string
πŸ“– Get content by reference$file->get_content_by_refπŸ“„ Return the file's content as a scalar reference (memory efficient)
✏️ Replace content$file->replace_content( $content )πŸ”„ Replace the in-memory content of the file
✏️ Rename file$file->rename( $new_name )🏷️ Rename the file in the archive
πŸ” Validate checksum$file->validateβœ… Verify tar header checksum
πŸ” Check type$file->is_file, $file->is_dir, ...πŸ”Ž Check file type (file, dir, symlink, etc.)
πŸ”„ Change mode$file->chmod $modeπŸ” Change file permissions
πŸ”„ Change owner$file->chown( $user [, $group] )πŸ‘€ Change file ownership

πŸ“‹ SYNOPSIS

my @items = $tar->get_files;
print $_->name, ' ', $_->size, "\n" for @items;
print $object->get_content;
$object->replace_content('new content');
$object->rename( 'new/full/path/to/file.c' );

πŸ“ 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.

πŸ”‘ Accessors

A lot of the methods in this package are accessors to the various fields in the tar header:

βš™οΈ Methods

πŸ“¦ Archive::Tar::File->new( file => $path )

Returns a new Archive::Tar::File object from an existing file. Returns undef on failure.

πŸ“¦ Archive::Tar::File->new( data => $path, $data, $opt )

Returns a new Archive::Tar::File object from data. $path defines the file name (which need not exist), $data the file contents, and $opt is a reference to a hash of attributes which may be used to override the default attributes (fields in the tar header). Returns undef on failure.

πŸ“¦ Archive::Tar::File->new( chunk => $chunk )

Returns a new Archive::Tar::File object from a raw 512-byte tar archive chunk. Returns undef on failure.

πŸ“€ $bool = $file->extract( [ $alternative_name ] )

Extract this object, optionally to an alternative name. See β€œArchive::Tar->extract_file” for details. Returns true on success and false on failure.

πŸ“ $path = $file->full_path

Returns the full path from the tar header; this is basically a concatenation of the β€œprefix” and β€œname” fields.

βœ… $bool = $file->validate

Done by Archive::Tar internally when reading the tar file: validate the header against the checksum to ensure integer tar file. Returns true on success, false on failure.

πŸ“„ $bool = $file->has_content

Returns a boolean to indicate whether the current object has content. Some special files like directories never have content. This method is mainly to avoid warnings for uninitialized values.

πŸ“„ $content = $file->get_content

Returns the current content for the in-memory file.

πŸ“„ $cref = $file->get_content_by_ref

Returns the current content for the in-memory file as a scalar reference. Saves memory for large files.

✏️ $bool = $file->replace_content( $content )

Replace the current content of the file with new content. This only affects the in-memory archive, not the on-disk version until you write it. Returns true on success, false on failure.

🏷️ $bool = $file->rename( $new_name )

Rename the current file to $new_name. Note that you must specify a Unix path. Returns true on success and false on failure.

πŸ” $bool = $file->chmod $mode

Change mode of $file to $mode. The mode can be a string or a number interpreted as octal. Returns true on success and false on failure.

πŸ‘€ $bool = $file->chown( $user [, $group])

Change owner of $file to $user. If a $group is given, that is changed as well. You can also pass a single parameter with a colon separating the user and group (e.g., β€˜root:wheel’). Returns true on success and false on failure.

πŸ” Convenience Methods

To quickly check the type of a β€œArchive::Tar::File” object, you can use the following methods:


perl v5.34.0   2026-06-23   Archive::Tar::File(3perl)

Archive::Tar::File
πŸ“– NAME πŸš€ Quick Reference πŸ“‹ SYNOPSIS πŸ“ DESCRIPTION πŸ”‘ Accessors βš™οΈ Methods
πŸ“¦ Archive::Tar::File->new( file => $path ) πŸ“¦ Archive::Tar::File->new( data => $path, $data, $opt ) πŸ“¦ Archive::Tar::File->new( chunk => $chunk ) πŸ“€ $bool = $file->extract( [ $alternative_name ] ) πŸ“ $path = $file->full_path βœ… $bool = $file->validate πŸ“„ $bool = $file->has_content πŸ“„ $content = $file->get_content πŸ“„ $cref = $file->get_content_by_ref ✏️ $bool = $file->replace_content( $content ) 🏷️ $bool = $file->rename( $new_name ) πŸ” $bool = $file->chmod $mode πŸ‘€ $bool = $file->chown( $user [, $group])
πŸ” Convenience Methods

Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-23 09:05 @216.73.216.102
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^