Debian Codegraph @

upstream/debian-unstable/man3/Archive::Tar::File.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "Archive::Tar::File 3perl"
58 .TH Archive::Tar::File 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 Archive::Tar::File \- a subclass for in\-memory extracted file from Archive::Tar
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 1
68 \& my @items = $tar\->get_files;
69 \&
70 \& print $_\->name, \*(Aq \*(Aq, $_\->size, "\en" for @items;
71 \&
72 \& print $object\->get_content;
73 \& $object\->replace_content(\*(Aqnew content\*(Aq);
74 \&
75 \& $object\->rename( \*(Aqnew/full/path/to/file.c\*(Aq );
76 .Ve
77 .SH DESCRIPTION
78 .IX Header "DESCRIPTION"
79 Archive::Tar::File provides a neat little object layer for in-memory
80 extracted files. It's mostly used internally in Archive::Tar to tidy
81 up the code, but there's no reason users shouldn't use this API as
82 well.
83 .SS Accessors
84 .IX Subsection "Accessors"
85 A lot of the methods in this package are accessors to the various
86 fields in the tar header:
87 .IP name 4
88 .IX Item "name"
89 The file's name
90 .IP mode 4
91 .IX Item "mode"
92 The file's mode
93 .IP uid 4
94 .IX Item "uid"
95 The user id owning the file
96 .IP gid 4
97 .IX Item "gid"
98 The group id owning the file
99 .IP size 4
100 .IX Item "size"
101 File size in bytes
102 .IP mtime 4
103 .IX Item "mtime"
104 Modification time. Adjusted to mac-time on MacOS if required
105 .IP chksum 4
106 .IX Item "chksum"
107 Checksum field for the tar header
108 .IP type 4
109 .IX Item "type"
110 File type \-\- numeric, but comparable to exported constants \-\- see
111 Archive::Tar's documentation
112 .IP linkname 4
113 .IX Item "linkname"
114 If the file is a symlink, the file it's pointing to
115 .IP magic 4
116 .IX Item "magic"
117 Tar magic string \-\- not useful for most users
118 .IP version 4
119 .IX Item "version"
120 Tar version string \-\- not useful for most users
121 .IP uname 4
122 .IX Item "uname"
123 The user name that owns the file
124 .IP gname 4
125 .IX Item "gname"
126 The group name that owns the file
127 .IP devmajor 4
128 .IX Item "devmajor"
129 Device major number in case of a special file
130 .IP devminor 4
131 .IX Item "devminor"
132 Device minor number in case of a special file
133 .IP prefix 4
134 .IX Item "prefix"
135 Any directory to prefix to the extraction path, if any
136 .IP raw 4
137 .IX Item "raw"
138 Raw tar header \-\- not useful for most users
139 .SH Methods
140 .IX Header "Methods"
141 .ie n .SS "Archive::Tar::File\->new( file => $path )"
142 .el .SS "Archive::Tar::File\->new( file => \f(CW$path\fP )"
143 .IX Subsection "Archive::Tar::File->new( file => $path )"
144 Returns a new Archive::Tar::File object from an existing file.
145 .PP
146 Returns undef on failure.
147 .ie n .SS "Archive::Tar::File\->new( data => $path, $data, $opt )"
148 .el .SS "Archive::Tar::File\->new( data => \f(CW$path\fP, \f(CW$data\fP, \f(CW$opt\fP )"
149 .IX Subsection "Archive::Tar::File->new( data => $path, $data, $opt )"
150 Returns a new Archive::Tar::File object from data.
151 .PP
152 \&\f(CW$path\fR defines the file name (which need not exist), \f(CW$data\fR the
153 file contents, and \f(CW$opt\fR is a reference to a hash of attributes
154 which may be used to override the default attributes (fields in the
155 tar header), which are described above in the Accessors section.
156 .PP
157 Returns undef on failure.
158 .ie n .SS "Archive::Tar::File\->new( chunk => $chunk )"
159 .el .SS "Archive::Tar::File\->new( chunk => \f(CW$chunk\fP )"
160 .IX Subsection "Archive::Tar::File->new( chunk => $chunk )"
161 Returns a new Archive::Tar::File object from a raw 512\-byte tar
162 archive chunk.
163 .PP
164 Returns undef on failure.
165 .ie n .SS "$bool = $file\->extract( [ $alternative_name ] )"
166 .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->extract( [ \f(CW$alternative_name\fP ] )"
167 .IX Subsection "$bool = $file->extract( [ $alternative_name ] )"
168 Extract this object, optionally to an alternative name.
169 .PP
170 See \f(CW\*(C`Archive::Tar\->extract_file\*(C'\fR for details.
171 .PP
172 Returns true on success and false on failure.
173 .ie n .SS "$path = $file\->full_path"
174 .el .SS "\f(CW$path\fP = \f(CW$file\fP\->full_path"
175 .IX Subsection "$path = $file->full_path"
176 Returns the full path from the tar header; this is basically a
177 concatenation of the \f(CW\*(C`prefix\*(C'\fR and \f(CW\*(C`name\*(C'\fR fields.
178 .ie n .SS "$bool = $file\->validate"
179 .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->validate"
180 .IX Subsection "$bool = $file->validate"
181 Done by Archive::Tar internally when reading the tar file:
182 validate the header against the checksum to ensure integer tar file.
183 .PP
184 Returns true on success, false on failure
185 .ie n .SS "$bool = $file\->has_content"
186 .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->has_content"
187 .IX Subsection "$bool = $file->has_content"
188 Returns a boolean to indicate whether the current object has content.
189 Some special files like directories and so on never will have any
190 content. This method is mainly to make sure you don't get warnings
191 for using uninitialized values when looking at an object's content.
192 .ie n .SS "$content = $file\->get_content"
193 .el .SS "\f(CW$content\fP = \f(CW$file\fP\->get_content"
194 .IX Subsection "$content = $file->get_content"
195 Returns the current content for the in-memory file
196 .ie n .SS "$cref = $file\->get_content_by_ref"
197 .el .SS "\f(CW$cref\fP = \f(CW$file\fP\->get_content_by_ref"
198 .IX Subsection "$cref = $file->get_content_by_ref"
199 Returns the current content for the in-memory file as a scalar
200 reference. Normal users won't need this, but it will save memory if
201 you are dealing with very large data files in your tar archive, since
202 it will pass the contents by reference, rather than make a copy of it
203 first.
204 .ie n .SS "$bool = $file\->replace_content( $content )"
205 .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->replace_content( \f(CW$content\fP )"
206 .IX Subsection "$bool = $file->replace_content( $content )"
207 Replace the current content of the file with the new content. This
208 only affects the in-memory archive, not the on-disk version until
209 you write it.
210 .PP
211 Returns true on success, false on failure.
212 .ie n .SS "$bool = $file\->rename( $new_name )"
213 .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->rename( \f(CW$new_name\fP )"
214 .IX Subsection "$bool = $file->rename( $new_name )"
215 Rename the current file to \f(CW$new_name\fR.
216 .PP
217 Note that you must specify a Unix path for \f(CW$new_name\fR, since per tar
218 standard, all files in the archive must be Unix paths.
219 .PP
220 Returns true on success and false on failure.
221 .ie n .SS "$bool = $file\->chmod( $mode )"
222 .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->chmod( \f(CW$mode\fP )"
223 .IX Subsection "$bool = $file->chmod( $mode )"
224 Change mode of \f(CW$file\fR to \f(CW$mode\fR. The mode can be a string or a number
225 which is interpreted as octal whether or not a leading 0 is given.
226 .PP
227 Returns true on success and false on failure.
228 .ie n .SS "$bool = $file\->chown( $user [, $group])"
229 .el .SS "\f(CW$bool\fP = \f(CW$file\fP\->chown( \f(CW$user\fP [, \f(CW$group\fP])"
230 .IX Subsection "$bool = $file->chown( $user [, $group])"
231 Change owner of \f(CW$file\fR to \f(CW$user\fR. If a \f(CW$group\fR is given that is changed
232 as well. You can also pass a single parameter with a colon separating the
233 use and group as in 'root:wheel'.
234 .PP
235 Returns true on success and false on failure.
236 .SH "Convenience methods"
237 .IX Header "Convenience methods"
238 To quickly check the type of a \f(CW\*(C`Archive::Tar::File\*(C'\fR object, you can
239 use the following methods:
240 .ie n .IP $file\->is_file 4
241 .el .IP \f(CW$file\fR\->is_file 4
242 .IX Item "$file->is_file"
243 Returns true if the file is of type \f(CW\*(C`file\*(C'\fR
244 .ie n .IP $file\->is_dir 4
245 .el .IP \f(CW$file\fR\->is_dir 4
246 .IX Item "$file->is_dir"
247 Returns true if the file is of type \f(CW\*(C`dir\*(C'\fR
248 .ie n .IP $file\->is_hardlink 4
249 .el .IP \f(CW$file\fR\->is_hardlink 4
250 .IX Item "$file->is_hardlink"
251 Returns true if the file is of type \f(CW\*(C`hardlink\*(C'\fR
252 .ie n .IP $file\->is_symlink 4
253 .el .IP \f(CW$file\fR\->is_symlink 4
254 .IX Item "$file->is_symlink"
255 Returns true if the file is of type \f(CW\*(C`symlink\*(C'\fR
256 .ie n .IP $file\->is_chardev 4
257 .el .IP \f(CW$file\fR\->is_chardev 4
258 .IX Item "$file->is_chardev"
259 Returns true if the file is of type \f(CW\*(C`chardev\*(C'\fR
260 .ie n .IP $file\->is_blockdev 4
261 .el .IP \f(CW$file\fR\->is_blockdev 4
262 .IX Item "$file->is_blockdev"
263 Returns true if the file is of type \f(CW\*(C`blockdev\*(C'\fR
264 .ie n .IP $file\->is_fifo 4
265 .el .IP \f(CW$file\fR\->is_fifo 4
266 .IX Item "$file->is_fifo"
267 Returns true if the file is of type \f(CW\*(C`fifo\*(C'\fR
268 .ie n .IP $file\->is_socket 4
269 .el .IP \f(CW$file\fR\->is_socket 4
270 .IX Item "$file->is_socket"
271 Returns true if the file is of type \f(CW\*(C`socket\*(C'\fR
272 .ie n .IP $file\->is_longlink 4
273 .el .IP \f(CW$file\fR\->is_longlink 4
274 .IX Item "$file->is_longlink"
275 Returns true if the file is of type \f(CW\*(C`LongLink\*(C'\fR.
276 Should not happen after a successful \f(CW\*(C`read\*(C'\fR.
277 .ie n .IP $file\->is_label 4
278 .el .IP \f(CW$file\fR\->is_label 4
279 .IX Item "$file->is_label"
280 Returns true if the file is of type \f(CW\*(C`Label\*(C'\fR.
281 Should not happen after a successful \f(CW\*(C`read\*(C'\fR.
282 .ie n .IP $file\->is_unknown 4
283 .el .IP \f(CW$file\fR\->is_unknown 4
284 .IX Item "$file->is_unknown"
285 Returns true if the file type is \f(CW\*(C`unknown\*(C'\fR