{
    "mode": "perldoc",
    "parameter": "Archive::Tar::File",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Archive%3A%3ATar%3A%3AFile/json",
    "generated": "2026-06-10T09:48:30Z",
    "synopsis": "my @items = $tar->getfiles;\nprint $->name, ' ', $->size, \"\\n\" for @items;\nprint $object->getcontent;\n$object->replacecontent('new content');\n$object->rename( 'new/full/path/to/file.c' );",
    "sections": {
        "NAME": {
            "content": "Archive::Tar::File - a subclass for in-memory extracted file from Archive::Tar\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "my @items = $tar->getfiles;\n\nprint $->name, ' ', $->size, \"\\n\" for @items;\n\nprint $object->getcontent;\n$object->replacecontent('new content');\n\n$object->rename( 'new/full/path/to/file.c' );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Archive::Tar::Files provides a neat little object layer for in-memory extracted files. It's\nmostly used internally in Archive::Tar to tidy up the code, but there's no reason users\nshouldn't use this API as well.\n",
            "subsections": [
                {
                    "name": "Accessors",
                    "content": "A lot of the methods in this package are accessors to the various fields in the tar header:\n\nname\nThe file's name\n\nmode\nThe file's mode\n\nuid The user id owning the file\n\ngid The group id owning the file\n\nsize\nFile size in bytes\n\nmtime\nModification time. Adjusted to mac-time on MacOS if required\n\nchksum\nChecksum field for the tar header\n\ntype\nFile type -- numeric, but comparable to exported constants -- see Archive::Tar's\ndocumentation\n\nlinkname\nIf the file is a symlink, the file it's pointing to\n\nmagic\nTar magic string -- not useful for most users\n\nversion\nTar version string -- not useful for most users\n\nuname\nThe user name that owns the file\n\ngname\nThe group name that owns the file\n\ndevmajor\nDevice major number in case of a special file\n\ndevminor\nDevice minor number in case of a special file\n\nprefix\nAny directory to prefix to the extraction path, if any\n\nraw Raw tar header -- not useful for most users\n"
                }
            ]
        },
        "Methods": {
            "content": "Archive::Tar::File->new( file => $path )\nReturns a new Archive::Tar::File object from an existing file.\n\nReturns undef on failure.\n\nArchive::Tar::File->new( data => $path, $data, $opt )\nReturns a new Archive::Tar::File object from data.\n\n$path defines the file name (which need not exist), $data the file contents, and $opt is a\nreference to a hash of attributes which may be used to override the default attributes (fields\nin the tar header), which are described above in the Accessors section.\n\nReturns undef on failure.\n\nArchive::Tar::File->new( chunk => $chunk )\nReturns a new Archive::Tar::File object from a raw 512-byte tar archive chunk.\n\nReturns undef on failure.\n\n$bool = $file->extract( [ $alternativename ] )\nExtract this object, optionally to an alternative name.\n\nSee \"Archive::Tar->extractfile\" for details.\n\nReturns true on success and false on failure.\n\n$path = $file->fullpath\nReturns the full path from the tar header; this is basically a concatenation of the \"prefix\" and\n\"name\" fields.\n\n$bool = $file->validate\nDone by Archive::Tar internally when reading the tar file: validate the header against the\nchecksum to ensure integer tar file.\n\nReturns true on success, false on failure\n\n$bool = $file->hascontent\nReturns a boolean to indicate whether the current object has content. Some special files like\ndirectories and so on never will have any content. This method is mainly to make sure you don't\nget warnings for using uninitialized values when looking at an object's content.\n\n$content = $file->getcontent\nReturns the current content for the in-memory file\n\n$cref = $file->getcontentbyref\nReturns the current content for the in-memory file as a scalar reference. Normal users won't\nneed this, but it will save memory if you are dealing with very large data files in your tar\narchive, since it will pass the contents by reference, rather than make a copy of it first.\n\n$bool = $file->replacecontent( $content )\nReplace the current content of the file with the new content. This only affects the in-memory\narchive, not the on-disk version until you write it.\n\nReturns true on success, false on failure.\n\n$bool = $file->rename( $newname )\nRename the current file to $newname.\n\nNote that you must specify a Unix path for $newname, since per tar standard, all files in the\narchive must be Unix paths.\n\nReturns true on success and false on failure.\n\n$bool = $file->chmod $mode)\nChange mode of $file to $mode. The mode can be a string or a number which is interpreted as\noctal whether or not a leading 0 is given.\n\nReturns true on success and false on failure.\n\n$bool = $file->chown( $user [, $group])\nChange owner of $file to $user. If a $group is given that is changed as well. You can also pass\na single parameter with a colon separating the use and group as in 'root:wheel'.\n\nReturns true on success and false on failure.\n",
            "subsections": []
        },
        "Convenience methods": {
            "content": "To quickly check the type of a \"Archive::Tar::File\" object, you can use the following methods:\n\n$file->isfile\nReturns true if the file is of type \"file\"\n\n$file->isdir\nReturns true if the file is of type \"dir\"\n\n$file->ishardlink\nReturns true if the file is of type \"hardlink\"\n\n$file->issymlink\nReturns true if the file is of type \"symlink\"\n\n$file->ischardev\nReturns true if the file is of type \"chardev\"\n\n$file->isblockdev\nReturns true if the file is of type \"blockdev\"\n\n$file->isfifo\nReturns true if the file is of type \"fifo\"\n\n$file->issocket\nReturns true if the file is of type \"socket\"\n\n$file->islonglink\nReturns true if the file is of type \"LongLink\". Should not happen after a successful \"read\".\n\n$file->islabel\nReturns true if the file is of type \"Label\". Should not happen after a successful \"read\".\n\n$file->isunknown\nReturns true if the file type is \"unknown\"\n",
            "subsections": []
        }
    },
    "summary": "Archive::Tar::File - a subclass for in-memory extracted file from Archive::Tar",
    "flags": [],
    "examples": [],
    "see_also": []
}