1Archive::Tar::File(3) User Contributed Perl DocumentationArchive::Tar::File(3)
2
3
4

NAME

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

SYNOPSIS

10           my @items = $tar->get_files;
11
12           print $_->name, ' ', $_->size, "\n" for @items;
13
14           print $object->get_content;
15           $object->replace_content('new content');
16
17           $object->rename( 'new/full/path/to/file.c' );
18

DESCRIPTION

20       Archive::Tar::Files provides a neat little object layer for in-memory
21       extracted files. It's mostly used internally in Archive::Tar to tidy up
22       the code, but there's no reason users shouldn't use this API as well.
23
24   Accessors
25       A lot of the methods in this package are accessors to the various
26       fields in the tar header:
27
28       name
29           The file's name
30
31       mode
32           The file's mode
33
34       uid The user id owning the file
35
36       gid The group id owning the file
37
38       size
39           File size in bytes
40
41       mtime
42           Modification time. Adjusted to mac-time on MacOS if required
43
44       chksum
45           Checksum field for the tar header
46
47       type
48           File type -- numeric, but comparable to exported constants -- see
49           Archive::Tar's documentation
50
51       linkname
52           If the file is a symlink, the file it's pointing to
53
54       magic
55           Tar magic string -- not useful for most users
56
57       version
58           Tar version string -- not useful for most users
59
60       uname
61           The user name that owns the file
62
63       gname
64           The group name that owns the file
65
66       devmajor
67           Device major number in case of a special file
68
69       devminor
70           Device minor number in case of a special file
71
72       prefix
73           Any directory to prefix to the extraction path, if any
74
75       raw Raw tar header -- not useful for most users
76

Methods

78   Archive::Tar::File->new( file => $path )
79       Returns a new Archive::Tar::File object from an existing file.
80
81       Returns undef on failure.
82
83   Archive::Tar::File->new( data => $path, $data, $opt )
84       Returns a new Archive::Tar::File object from data.
85
86       $path defines the file name (which need not exist), $data the file
87       contents, and $opt is a reference to a hash of attributes which may be
88       used to override the default attributes (fields in the tar header),
89       which are described above in the Accessors section.
90
91       Returns undef on failure.
92
93   Archive::Tar::File->new( chunk => $chunk )
94       Returns a new Archive::Tar::File object from a raw 512-byte tar archive
95       chunk.
96
97       Returns undef on failure.
98
99   $bool = $file->extract( [ $alternative_name ] )
100       Extract this object, optionally to an alternative name.
101
102       See "Archive::Tar->extract_file" for details.
103
104       Returns true on success and false on failure.
105
106   $path = $file->full_path
107       Returns the full path from the tar header; this is basically a
108       concatenation of the "prefix" and "name" fields.
109
110   $bool = $file->validate
111       Done by Archive::Tar internally when reading the tar file: validate the
112       header against the checksum to ensure integer tar file.
113
114       Returns true on success, false on failure
115
116   $bool = $file->has_content
117       Returns a boolean to indicate whether the current object has content.
118       Some special files like directories and so on never will have any
119       content. This method is mainly to make sure you don't get warnings for
120       using uninitialized values when looking at an object's content.
121
122   $content = $file->get_content
123       Returns the current content for the in-memory file
124
125   $cref = $file->get_content_by_ref
126       Returns the current content for the in-memory file as a scalar
127       reference. Normal users won't need this, but it will save memory if you
128       are dealing with very large data files in your tar archive, since it
129       will pass the contents by reference, rather than make a copy of it
130       first.
131
132   $bool = $file->replace_content( $content )
133       Replace the current content of the file with the new content. This only
134       affects the in-memory archive, not the on-disk version until you write
135       it.
136
137       Returns true on success, false on failure.
138
139   $bool = $file->rename( $new_name )
140       Rename the current file to $new_name.
141
142       Note that you must specify a Unix path for $new_name, since per tar
143       standard, all files in the archive must be Unix paths.
144
145       Returns true on success and false on failure.
146
147   $bool = $file->chmod $mode)
148       Change mode of $file to $mode. The mode can be a string or a number
149       which is interpreted as octal whether or not a leading 0 is given.
150
151       Returns true on success and false on failure.
152
153   $bool = $file->chown( $user [, $group])
154       Change owner of $file to $user. If a $group is given that is changed as
155       well. You can also pass a single parameter with a colon separating the
156       use and group as in 'root:wheel'.
157
158       Returns true on success and false on failure.
159

Convenience methods

161       To quickly check the type of a "Archive::Tar::File" object, you can use
162       the following methods:
163
164       $file->is_file
165           Returns true if the file is of type "file"
166
167       $file->is_dir
168           Returns true if the file is of type "dir"
169
170       $file->is_hardlink
171           Returns true if the file is of type "hardlink"
172
173       $file->is_symlink
174           Returns true if the file is of type "symlink"
175
176       $file->is_chardev
177           Returns true if the file is of type "chardev"
178
179       $file->is_blockdev
180           Returns true if the file is of type "blockdev"
181
182       $file->is_fifo
183           Returns true if the file is of type "fifo"
184
185       $file->is_socket
186           Returns true if the file is of type "socket"
187
188       $file->is_longlink
189           Returns true if the file is of type "LongLink".  Should not happen
190           after a successful "read".
191
192       $file->is_label
193           Returns true if the file is of type "Label".  Should not happen
194           after a successful "read".
195
196       $file->is_unknown
197           Returns true if the file type is "unknown"
198
199
200
201perl v5.32.1                      2021-01-26             Archive::Tar::File(3)
Impressum