]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/tarstrm.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxTarInputStream
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxTarInputStream
12 Input stream for reading tar files.
14 wxTarInputStream::GetNextEntry returns an
15 wxTarEntry object containing the meta-data
16 for the next entry in the tar (and gives away ownership). Reading from
17 the wxTarInputStream then returns the entry's data. Eof() becomes @true
18 after an attempt has been made to read past the end of the entry's data.
19 When there are no more entries, GetNextEntry() returns @NULL and sets Eof().
21 Tar entries are seekable if the parent stream is seekable. In practice this
22 usually means they are only seekable if the tar is stored as a local file and
28 @see @ref overview_wxarcbyname "Looking up an archive entry by name"
30 class wxTarInputStream
: public wxArchiveInputStream
35 Constructor. In a Unicode build the second parameter @a conv is
36 used to translate fields from the standard tar header into Unicode. It has
37 no effect on the stream's data. @a conv is only used for the standard
38 tar headers, any pax extended headers are always UTF-8 encoded.
39 If the parent stream is passed as a pointer then the new filter stream
40 takes ownership of it. If it is passed by reference then it does not.
42 wxTarInputStream(wxInputStream
& stream
,
43 wxMBConv
& conv
= wxConvLocal
);
44 wxTarInputStream(wxInputStream
* stream
,
45 wxMBConv
& conv
= wxConvLocal
);
49 Closes the current entry. On a non-seekable stream reads to the end of
50 the current entry first.
55 Closes the current entry if one is open, then reads the meta-data for
56 the next entry and returns it in a wxTarEntry
57 object, giving away ownership. The stream is then open and can be read.
59 wxTarEntry
* GetNextEntry();
62 Closes the current entry if one is open, then opens the entry specified
63 by the @a entry object.
64 @a entry should be from the same tar file, and the tar should
65 be on a seekable stream.
67 bool OpenEntry(wxTarEntry
& entry
);
73 @class wxTarClassFactory
75 Class factory for the tar archive format. See the base class
81 @see @ref overview_wxarc "Archive formats such as zip", @ref
82 overview_wxarcgeneric "Generic archive programming", wxTarEntry, wxTarInputStream, wxTarOutputStream
84 class wxTarClassFactory
: public wxArchiveClassFactory
93 @class wxTarOutputStream
95 Output stream for writing tar files.
97 wxTarOutputStream::PutNextEntry is used to create
98 a new entry in the output tar, then the entry's data is written to the
99 wxTarOutputStream. Another call to PutNextEntry() closes the current
100 entry and begins the next.
105 @see @ref overview_wxarc "Archive formats such as zip", wxTarEntry,
108 class wxTarOutputStream
: public wxArchiveOutputStream
113 If the parent stream is passed as a pointer then the new filter stream
114 takes ownership of it. If it is passed by reference then it does not.
115 In a Unicode build the third parameter @a conv is used to translate the
116 headers fields into an 8-bit encoding. It has no effect on the stream's data.
117 When the @a format is @e wxTAR_PAX, pax extended headers are generated
118 when any header field will not fit the standard tar header block or if it
119 uses any non-ascii characters.
120 Extended headers are stored as extra 'files' within the tar, and will be
121 extracted as such by any other tar program that does not understand them.
122 The @a conv parameter only affect the standard tar headers, the extended
123 headers are always UTF-8 encoded.
124 When the @a format is @e wxTAR_USTAR, no extended headers are
125 generated, and instead a warning message is logged if any header field
128 wxTarOutputStream(wxOutputStream
& stream
,
129 wxTarFormat format
= wxTAR_PAX
,
130 wxMBConv
& conv
= wxConvLocal
);
131 wxTarOutputStream(wxOutputStream
* stream
,
132 wxTarFormat format
= wxTAR_PAX
,
133 wxMBConv
& conv
= wxConvLocal
);
137 The destructor calls Close() to finish
138 writing the tar if it has not been called already.
140 ~wxTarOutputStream();
143 Finishes writing the tar, returning @true if successful.
144 Called by the destructor if not called explicitly.
149 Close the current entry. It is called implicitly whenever another new
150 entry is created with CopyEntry()
151 or PutNextEntry(), or
152 when the tar is closed.
157 See wxArchiveOutputStream::CopyArchiveMetaData.
158 For the tar format this function does nothing.
160 bool CopyArchiveMetaData(wxTarInputStream
& s
);
163 Takes ownership of @a entry and uses it to create a new entry
164 in the tar. @a entry is then opened in @a inputStream and its contents
165 copied to this stream.
166 For some other archive formats CopyEntry() is much more efficient than
167 transferring the data using Read() and Write() since it will copy them
168 without decompressing and recompressing them. For tar however it makes
170 For tars on seekable streams, @a entry must be from the same tar file
171 as @e stream. For non-seekable streams, @a entry must also be the
172 last thing read from @e inputStream.
174 bool CopyEntry(wxTarEntry
* entry
, wxTarInputStream
& inputStream
);
178 The tar is zero padded to round its size up to @e BlockingFactor * 512 bytes.
179 Defaults to 10 for @e wxTAR_PAX and 20 for @e wxTAR_USTAR
180 (see the @ref wxtaroutputstream() constructor), as
181 specified in the POSIX standards.
183 int GetBlockingFactor();
184 const void SetBlockingFactor(int factor
);
189 Create a new directory entry
190 (see wxArchiveEntry::IsDir)
191 with the given name and timestamp.
193 also be used to create directory entries, by supplying a name with
194 a trailing path separator.
196 bool PutNextDirEntry(const wxString
& name
);
200 , @b wxFileOffset@e size = wxInvalidOffset)
201 Create a new entry with the given name, timestamp and size.
203 bool PutNextEntry(wxTarEntry
* entry
);
204 bool PutNextEntry(const wxString
& name
);
213 Holds the meta-data for an entry in a tar.
218 @see @ref overview_wxarc "Archive formats such as zip", wxTarInputStream,
221 class wxTarEntry
: public wxArchiveEntry
228 wxTarEntry(const wxString
& name
= wxEmptyString
);
229 wxTarEntry(const wxTarEntry
& entry
);
234 The entry's access time stamp. See also
235 wxArchiveEntry::Get/SetDateTime.
237 wxDateTime
GetAccessTime();
238 const void SetAccessTime(const wxDateTime
& dt
);
243 The entry's creation time stamp. See also
244 wxArchiveEntry::Get/SetDateTime.
246 wxDateTime
GetCreateTime();
247 const void SetCreateTime(const wxDateTime
& dt
);
252 OS specific IDs defining a device, these are only meaningful when
253 TypeFlag() is set to @e wxTAR_CHRTYPE
257 const int GetDevMinor();
258 const void SetDevMajor(int dev
);
259 void SetDevMinor(int dev
);
264 The user ID and group ID that has @ref mode() permissions over
265 this entry. These values aren't usually useful unless the file will only be
266 restored to the same system it originated from. @ref unamegname()
267 "Get/SetGroupName and
268 Get/SetUserName" can be used instead.
271 const int GetUserId();
272 const void SetGroupId(int id
);
273 void SetUserId(int id
);
278 The names of the user and group that has @ref mode() permissions
279 over this entry. These are not present in very old tars.
281 wxString
GetGroupName();
282 const wxString
GetUserName();
283 const void SetGroupName(const wxString
& group
);
284 void SetUserName(const wxString
& user
);
289 The filename of a previous entry in the tar that this entry is a link to.
290 Only meaningful when TypeFlag() is set
291 to @e wxTAR_LNKTYPE or @e wxTAR_SYMTYPE.
293 wxString
GetLinkName();
294 const void SetLinkName(const wxString
& link
);
299 UNIX permission bits for this entry. Giving read, write and execute permissions
300 to the file's @ref unamegname() "User and Group" and to others.
301 Symbols are defined for them in wx/file.h.
304 const void SetMode(int mode
);
309 The size of the entry's data in bytes.
310 The tar archive format stores the entry's size ahead of the entry's data.
311 Therefore when creating an archive on a non-seekable stream it is necessary to
312 supply the correct size when each entry is created. For seekable streams this
313 is not necessary as wxTarOutputStream will attempt
314 to seek back and fix the entry's header when the entry is closed, though it is
315 still more efficient if the size is given beforehand.
317 void SetSize(wxFileOffset size
) const;
318 wxFileOffset
GetSize() const;
323 Returns the type of the entry. It should be one of the following:
325 When creating archives use just these values. When reading archives
326 any other values should be treated as @e wxTAR_REGTYPE.
329 const void SetTypeFlag(int type
);
334 A static member that translates a filename into the internal format used
335 within the archive. If the third parameter is provided, the bool pointed
336 to is set to indicate whether the name looks like a directory name
337 (i.e. has a trailing path separator).
339 wxString
GetInternalName();
340 const wxString
GetInternalName(const wxString
& name
,
341 wxPathFormat format
= wxPATH_NATIVE
,
342 bool* pIsDir
= NULL
);
348 wxTarEntry
& operator operator=(const wxTarEntry
& entry
);