]>
git.saurik.com Git - wxWidgets.git/blob - interface/tarstrm.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxTarInputStream
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxTarInputStream
13 Input stream for reading tar files.
15 wxTarInputStream::GetNextEntry returns an
16 wxTarEntry object containing the meta-data
17 for the next entry in the tar (and gives away ownership). Reading from
18 the wxTarInputStream then returns the entry's data. Eof() becomes @true
19 after an attempt has been made to read past the end of the entry's data.
20 When there are no more entries, GetNextEntry() returns @NULL and sets Eof().
22 Tar entries are seekable if the parent stream is seekable. In practice this
23 usually means they are only seekable if the tar is stored as a local file and
29 @see @ref overview_wxarcbyname "Looking up an archive entry by name"
31 class wxTarInputStream
: public wxArchiveInputStream
36 Constructor. In a Unicode build the second parameter @a conv is
37 used to translate fields from the standard tar header into Unicode. It has
38 no effect on the stream's data. @a conv is only used for the standard
39 tar headers, any pax extended headers are always UTF-8 encoded.
40 If the parent stream is passed as a pointer then the new filter stream
41 takes ownership of it. If it is passed by reference then it does not.
43 wxTarInputStream(wxInputStream
& stream
,
44 wxMBConv
& conv
= wxConvLocal
);
45 wxTarInputStream(wxInputStream
* stream
,
46 wxMBConv
& conv
= wxConvLocal
);
50 Closes the current entry. On a non-seekable stream reads to the end of
51 the current entry first.
56 Closes the current entry if one is open, then reads the meta-data for
57 the next entry and returns it in a wxTarEntry
58 object, giving away ownership. The stream is then open and can be read.
60 wxTarEntry
* GetNextEntry();
63 Closes the current entry if one is open, then opens the entry specified
64 by the @a entry object.
65 @a entry should be from the same tar file, and the tar should
66 be on a seekable stream.
68 bool OpenEntry(wxTarEntry
& entry
);
74 @class wxTarClassFactory
77 Class factory for the tar archive format. See the base class
83 @see @ref overview_wxarc "Archive formats such as zip", @ref
84 overview_wxarcgeneric "Generic archive programming", wxTarEntry, wxTarInputStream, wxTarOutputStream
86 class wxTarClassFactory
: public wxArchiveClassFactory
95 @class wxTarOutputStream
98 Output stream for writing tar files.
100 wxTarOutputStream::PutNextEntry is used to create
101 a new entry in the output tar, then the entry's data is written to the
102 wxTarOutputStream. Another call to PutNextEntry() closes the current
103 entry and begins the next.
108 @see @ref overview_wxarc "Archive formats such as zip", wxTarEntry,
111 class wxTarOutputStream
: public wxArchiveOutputStream
116 If the parent stream is passed as a pointer then the new filter stream
117 takes ownership of it. If it is passed by reference then it does not.
118 In a Unicode build the third parameter @a conv is used to translate the
119 headers fields into an 8-bit encoding. It has no effect on the stream's data.
120 When the @a format is @e wxTAR_PAX, pax extended headers are generated
121 when any header field will not fit the standard tar header block or if it
122 uses any non-ascii characters.
123 Extended headers are stored as extra 'files' within the tar, and will be
124 extracted as such by any other tar program that does not understand them.
125 The @a conv parameter only affect the standard tar headers, the extended
126 headers are always UTF-8 encoded.
127 When the @a format is @e wxTAR_USTAR, no extended headers are
128 generated, and instead a warning message is logged if any header field
131 wxTarOutputStream(wxOutputStream
& stream
,
132 wxTarFormat format
= wxTAR_PAX
,
133 wxMBConv
& conv
= wxConvLocal
);
134 wxTarOutputStream(wxOutputStream
* stream
,
135 wxTarFormat format
= wxTAR_PAX
,
136 wxMBConv
& conv
= wxConvLocal
);
140 The destructor calls Close() to finish
141 writing the tar if it has not been called already.
143 ~wxTarOutputStream();
146 Finishes writing the tar, returning @true if successful.
147 Called by the destructor if not called explicitly.
152 Close the current entry. It is called implicitly whenever another new
153 entry is created with CopyEntry()
154 or PutNextEntry(), or
155 when the tar is closed.
160 See wxArchiveOutputStream::CopyArchiveMetaData.
161 For the tar format this function does nothing.
163 bool CopyArchiveMetaData(wxTarInputStream
& s
);
166 Takes ownership of @a entry and uses it to create a new entry
167 in the tar. @a entry is then opened in @a inputStream and its contents
168 copied to this stream.
169 For some other archive formats CopyEntry() is much more efficient than
170 transferring the data using Read() and Write() since it will copy them
171 without decompressing and recompressing them. For tar however it makes
173 For tars on seekable streams, @a entry must be from the same tar file
174 as @e stream. For non-seekable streams, @a entry must also be the
175 last thing read from @e inputStream.
177 bool CopyEntry(wxTarEntry
* entry
, wxTarInputStream
& inputStream
);
181 The tar is zero padded to round its size up to @e BlockingFactor * 512 bytes.
182 Defaults to 10 for @e wxTAR_PAX and 20 for @e wxTAR_USTAR
183 (see the @ref wxtaroutputstream() constructor), as
184 specified in the POSIX standards.
186 int GetBlockingFactor();
187 const void SetBlockingFactor(int factor
);
192 Create a new directory entry
193 (see wxArchiveEntry::IsDir)
194 with the given name and timestamp.
196 also be used to create directory entries, by supplying a name with
197 a trailing path separator.
199 bool PutNextDirEntry(const wxString
& name
);
203 , @b wxFileOffset@e size = wxInvalidOffset)
204 Create a new entry with the given name, timestamp and size.
206 bool PutNextEntry(wxTarEntry
* entry
);
207 bool PutNextEntry(const wxString
& name
);
217 Holds the meta-data for an entry in a tar.
222 @see @ref overview_wxarc "Archive formats such as zip", wxTarInputStream,
225 class wxTarEntry
: public wxArchiveEntry
232 wxTarEntry(const wxString
& name
= wxEmptyString
);
233 wxTarEntry(const wxTarEntry
& entry
);
238 The entry's access time stamp. See also
239 wxArchiveEntry::Get/SetDateTime.
241 wxDateTime
GetAccessTime();
242 const void SetAccessTime(const wxDateTime
& dt
);
247 The entry's creation time stamp. See also
248 wxArchiveEntry::Get/SetDateTime.
250 wxDateTime
GetCreateTime();
251 const void SetCreateTime(const wxDateTime
& dt
);
256 OS specific IDs defining a device, these are only meaningful when
257 TypeFlag() is set to @e wxTAR_CHRTYPE
261 const int GetDevMinor();
262 const void SetDevMajor(int dev
);
263 void SetDevMinor(int dev
);
268 The user ID and group ID that has @ref mode() permissions over
269 this entry. These values aren't usually useful unless the file will only be
270 restored to the same system it originated from. @ref unamegname()
271 "Get/SetGroupName and
272 Get/SetUserName" can be used instead.
275 const int GetUserId();
276 const void SetGroupId(int id
);
277 void SetUserId(int id
);
282 The names of the user and group that has @ref mode() permissions
283 over this entry. These are not present in very old tars.
285 wxString
GetGroupName();
286 const wxString
GetUserName();
287 const void SetGroupName(const wxString
& group
);
288 void SetUserName(const wxString
& user
);
293 The filename of a previous entry in the tar that this entry is a link to.
294 Only meaningful when TypeFlag() is set
295 to @e wxTAR_LNKTYPE or @e wxTAR_SYMTYPE.
297 wxString
GetLinkName();
298 const void SetLinkName(const wxString
& link
);
303 UNIX permission bits for this entry. Giving read, write and execute permissions
304 to the file's @ref unamegname() "User and Group" and to others.
305 Symbols are defined for them in wx/file.h.
308 const void SetMode(int mode
);
313 The size of the entry's data in bytes.
314 The tar archive format stores the entry's size ahead of the entry's data.
315 Therefore when creating an archive on a non-seekable stream it is necessary to
316 supply the correct size when each entry is created. For seekable streams this
317 is not necessary as wxTarOutputStream will attempt
318 to seek back and fix the entry's header when the entry is closed, though it is
319 still more efficient if the size is given beforehand.
321 void SetSize(wxFileOffset size
) const;
322 wxFileOffset
GetSize() const;
327 Returns the type of the entry. It should be one of the following:
329 When creating archives use just these values. When reading archives
330 any other values should be treated as @e wxTAR_REGTYPE.
333 const void SetTypeFlag(int type
);
338 A static member that translates a filename into the internal format used
339 within the archive. If the third parameter is provided, the bool pointed
340 to is set to indicate whether the name looks like a directory name
341 (i.e. has a trailing path separator).
343 wxString
GetInternalName();
344 const wxString
GetInternalName(const wxString
& name
,
345 wxPathFormat format
= wxPATH_NATIVE
,
346 bool* pIsDir
= NULL
);
352 wxTarEntry
& operator operator=(const wxTarEntry
& entry
);