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

Convenience methods

148       To quickly check the type of a "Archive::Tar::File" object, you can use
149       the following methods:
150
151       $file->is_file
152           Returns true if the file is of type "file"
153
154       $file->is_dir
155           Returns true if the file is of type "dir"
156
157       $file->is_hardlink
158           Returns true if the file is of type "hardlink"
159
160       $file->is_symlink
161           Returns true if the file is of type "symlink"
162
163       $file->is_chardev
164           Returns true if the file is of type "chardev"
165
166       $file->is_blockdev
167           Returns true if the file is of type "blockdev"
168
169       $file->is_fifo
170           Returns true if the file is of type "fifo"
171
172       $file->is_socket
173           Returns true if the file is of type "socket"
174
175       $file->is_longlink
176           Returns true if the file is of type "LongLink".  Should not happen
177           after a successful "read".
178
179       $file->is_label
180           Returns true if the file is of type "Label".  Should not happen
181           after a successful "read".
182
183       $file->is_unknown
184           Returns true if the file type is "unknown"
185
186
187
188perl v5.12.1                      2010-07-09             Archive::Tar::File(3)
Impressum