1Archive::Tar::File(3) User Contributed Perl DocumentationArchive::Tar::File(3)
2
3
4
6 Archive::Tar::File - a subclass for in-memory extracted file from Ar‐
7 chive::Tar
8
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
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
26 A lot of the methods in this package are accessors to the various
27 fields in the tar header:
28
29 name
30 The file's name
31
32 mode
33 The file's mode
34
35 uid The user id owning the file
36
37 gid The group id owning the file
38
39 size
40 File size in bytes
41
42 mtime
43 Modification time. Adjusted to mac-time on MacOS if required
44
45 chksum
46 Checksum field for the tar header
47
48 type
49 File type -- numeric, but comparable to exported constants -- see
50 Archive::Tar's documentation
51
52 linkname
53 If the file is a symlink, the file it's pointing to
54
55 magic
56 Tar magic string -- not useful for most users
57
58 version
59 Tar version string -- not useful for most users
60
61 uname
62 The user name that owns the file
63
64 gname
65 The group name that owns the file
66
67 devmajor
68 Device major number in case of a special file
69
70 devminor
71 Device minor number in case of a special file
72
73 prefix
74 Any directory to prefix to the extraction path, if any
75
76 raw Raw tar header -- not useful for most users
77
79 new( file => $path )
80
81 Returns a new Archive::Tar::File object from an existing file.
82
83 Returns undef on failure.
84
85 new( data => $path, $data, $opt )
86
87 Returns a new Archive::Tar::File object from data.
88
89 $path defines the file name (which need not exist), $data the file con‐
90 tents, and $opt is a reference to a hash of attributes which may be
91 used to override the default attributes (fields in the tar header),
92 which are described above in the Accessors section.
93
94 Returns undef on failure.
95
96 new( chunk => $chunk )
97
98 Returns a new Archive::Tar::File object from a raw 512-byte tar archive
99 chunk.
100
101 Returns undef on failure.
102
103 full_path
104
105 Returns the full path from the tar header; this is basically a concate‐
106 nation of the "prefix" and "name" fields.
107
108 validate
109
110 Done by Archive::Tar internally when reading the tar file: validate the
111 header against the checksum to ensure integer tar file.
112
113 Returns true on success, false on failure
114
115 has_content
116
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 con‐
119 tent. 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 get_content
123
124 Returns the current content for the in-memory file
125
126 get_content_by_ref
127
128 Returns the current content for the in-memory file as a scalar refer‐
129 ence. Normal users won't need this, but it will save memory if you are
130 dealing with very large data files in your tar archive, since it will
131 pass the contents by reference, rather than make a copy of it first.
132
133 replace_content( $content )
134
135 Replace the current content of the file with the new content. This only
136 affects the in-memory archive, not the on-disk version until you write
137 it.
138
139 Returns true on success, false on failure.
140
141 rename( $new_name )
142
143 Rename the current file to $new_name.
144
145 Note that you must specify a Unix path for $new_name, since per tar
146 standard, all files in the archive must be Unix paths.
147
148 Returns true on success and false on failure.
149
151 To quickly check the type of a "Archive::Tar::File" object, you can use
152 the following methods:
153
154 is_file
155 Returns true if the file is of type "file"
156
157 is_dir
158 Returns true if the file is of type "dir"
159
160 is_hardlink
161 Returns true if the file is of type "hardlink"
162
163 is_symlink
164 Returns true if the file is of type "symlink"
165
166 is_chardev
167 Returns true if the file is of type "chardev"
168
169 is_blockdev
170 Returns true if the file is of type "blockdev"
171
172 is_fifo
173 Returns true if the file is of type "fifo"
174
175 is_socket
176 Returns true if the file is of type "socket"
177
178 is_longlink
179 Returns true if the file is of type "LongLink". Should not happen
180 after a successful "read".
181
182 is_label
183 Returns true if the file is of type "Label". Should not happen
184 after a successful "read".
185
186 is_unknown
187 Returns true if the file type is "unknown"
188
189
190
191perl v5.8.8 2006-08-01 Archive::Tar::File(3)