]>
git.saurik.com Git - wxWidgets.git/blob - interface/zipstrm.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxZipNotifier class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 If you need to know when a wxZipInputStream
15 you can create a notifier by deriving from this abstract base class,
16 overriding wxZipNotifier::OnEntryUpdated.
17 An instance of your notifier class can then be assigned to wxZipEntry
18 objects, using wxZipEntry::SetNotifier.
20 Setting a notifier is not usually necessary. It is used to handle
21 certain cases when modifying an zip in a pipeline (i.e. between
22 non-seekable streams).
23 See '@ref overview_wxarcnoseek "Archives on non-seekable streams"'.
29 @ref overview_wxarcnoseek "Archives on non-seekable streams", wxZipEntry,
30 wxZipInputStream, wxZipOutputStream
36 Override this to receive notifications when
37 an wxZipEntry object changes.
39 void OnEntryUpdated(wxZipEntry
& entry
);
47 Holds the meta-data for an entry in a zip.
53 @ref overview_wxarc "Archive formats such as zip", wxZipInputStream,
54 wxZipOutputStream, wxZipNotifier
56 class wxZipEntry
: public wxArchiveEntry
63 wxZipEntry(const wxString
& name
= wxEmptyString
);
64 wxZipEntry(const wxZipEntry
& entry
);
68 Make a copy of this entry.
74 A short comment for this entry.
76 wxString
GetComment();
77 void SetComment(const wxString
& comment
);
82 The low 8 bits are always the DOS/Windows file attributes for this entry.
83 The values of these attributes are given in the
84 enumeration @c wxZipAttributes.
86 The remaining bits can store platform specific permission bits or
87 attributes, and their meaning depends on the value
88 of @ref systemmadeby() SetSystemMadeBy.
89 If IsMadeByUnix() is @true then the
90 high 16 bits are unix mode bits.
92 The following other accessors access these bits:
94 @ref wxArchiveEntry::isreadonly IsReadOnly/SetIsReadOnly
96 @ref wxArchiveEntry::isdir IsDir/SetIsDir
98 @ref mode() Get/SetMode
100 wxUint32
GetExternalAttributes();
101 void SetExternalAttributes(wxUint32 attr
);
106 The extra field from the entry's central directory record.
108 The extra field is used to store platform or application specific
109 data. See Pkware's document 'appnote.txt' for information on its format.
111 const char* GetExtra();
112 size_t GetExtraLen();
113 void SetExtra(const char* extra
, size_t len
);
118 The extra field from the entry's local record.
120 The extra field is used to store platform or application specific
121 data. See Pkware's document 'appnote.txt' for information on its format.
123 const char* GetLocalExtra();
124 size_t GetLocalExtraLen();
125 void SetLocalExtra(const char* extra
, size_t len
);
130 The compression method. The enumeration @c wxZipMethod lists the
133 The default constructor sets this to wxZIP_METHOD_DEFAULT,
134 which allows wxZipOutputStream to
135 choose the method when writing the entry.
138 void SetMethod(int method
);
143 Sets the DOS attributes
144 in @ref externalattributes() GetExternalAttributes
145 to be consistent with the @c mode given.
147 If IsMadeByUnix() is @true then also
148 stores @c mode in GetExternalAttributes().
150 Note that the default constructor
151 sets @ref systemmadeby() GetSystemMadeBy to
152 wxZIP_SYSTEM_MSDOS by default. So to be able to store unix
153 permissions when creating zips, call SetSystemMadeBy(wxZIP_SYSTEM_UNIX).
156 void SetMode(int mode
);
161 The originating file-system. The default constructor sets this to
162 wxZIP_SYSTEM_MSDOS. Set it to wxZIP_SYSTEM_UNIX in order to be
163 able to store unix permissions using @ref mode() SetMode.
165 int GetSystemMadeBy();
166 void SetSystemMadeBy(int system
);
170 The compressed size of this entry in bytes.
172 off_t
GetCompressedSize();
175 CRC32 for this entry's data.
180 Returns a combination of the bits flags in the enumeration @c wxZipFlags.
186 A static member that translates a filename into the internal format used
187 within the archive. If the third parameter is provided, the bool pointed
188 to is set to indicate whether the name looks like a directory name
189 (i.e. has a trailing path separator).
191 @sa @ref overview_wxarcbyname "Looking up an archive entry by name"
193 wxString
GetInternalName();
194 wxString
GetInternalName(const wxString
& name
,
195 wxPathFormat format
= wxPATH_NATIVE
,
196 bool* pIsDir
= @NULL
);
200 Returns @true if @ref systemmadeby() GetSystemMadeBy
201 is a flavour of unix.
207 Indicates that this entry's data is text in an 8-bit encoding.
210 void SetIsText(bool isText
= @
true);
215 Sets the notifier for this entry.
216 Whenever the wxZipInputStream updates
217 this entry, it will then invoke the associated
218 notifier's wxZipNotifier::OnEntryUpdated
221 Setting a notifier is not usually necessary. It is used to handle
222 certain cases when modifying an zip in a pipeline (i.e. between
223 non-seekable streams).
225 @sa @ref overview_wxarcnoseek "Archives on non-seekable streams", wxZipNotifier
227 void SetNotifier(wxZipNotifier
& notifier
);
228 void UnsetNotifier();
234 wxZipEntry
& operator operator=(const wxZipEntry
& entry
);
239 @class wxZipInputStream
242 Input stream for reading zip files.
244 wxZipInputStream::GetNextEntry returns an
245 wxZipEntry object containing the meta-data
246 for the next entry in the zip (and gives away ownership). Reading from
247 the wxZipInputStream then returns the entry's data. Eof() becomes @true
248 after an attempt has been made to read past the end of the entry's data.
249 When there are no more entries, GetNextEntry() returns @NULL and sets Eof().
251 Note that in general zip entries are not seekable, and
252 wxZipInputStream::SeekI() always returns wxInvalidOffset.
258 @ref overview_wxarc "Archive formats such as zip", wxZipEntry, wxZipOutputStream
260 class wxZipInputStream
: public wxArchiveInputStream
265 Compatibility constructor (requires WXWIN_COMPATIBILITY_2_6).
267 When this constructor is used, an emulation of seeking is
268 switched on for compatibility with previous versions. Note however,
269 that it is deprecated.
271 wxZipInputStream(wxInputStream
& stream
,
272 wxMBConv
& conv
= wxConvLocal
);
273 wxZipInputStream(wxInputStream
* stream
,
274 wxMBConv
& conv
= wxConvLocal
);
275 wxZipInputStream(const wxString
& archive
,
276 const wxString
& file
);
280 Closes the current entry. On a non-seekable stream reads to the end of
281 the current entry first.
286 Returns the zip comment.
288 This is stored at the end of the zip, therefore when reading a zip
289 from a non-seekable stream, it returns the empty string until the
290 end of the zip has been reached, i.e. when GetNextEntry() returns
293 wxString
GetComment();
296 Closes the current entry if one is open, then reads the meta-data for
297 the next entry and returns it in a wxZipEntry
298 object, giving away ownership. The stream is then open and can be read.
300 wxZipEntry
* GetNextEntry();
303 For a zip on a seekable stream returns the total number of entries in
304 the zip. For zips on non-seekable streams returns the number of entries
305 returned so far by GetNextEntry().
307 int GetTotalEntries();
310 Closes the current entry if one is open, then opens the entry specified
311 by the @e entry object.
313 @e entry should be from the same zip file, and the zip should
314 be on a seekable stream.
316 bool OpenEntry(wxZipEntry
& entry
);
321 @class wxZipClassFactory
324 Class factory for the zip archive format. See the base class
331 @ref overview_wxarc "Archive formats such as zip", @ref overview_wxarcgeneric
332 "Generic archive programming", wxZipEntry, wxZipInputStream, wxZipOutputStream
334 class wxZipClassFactory
: public wxArchiveClassFactory
342 @class wxZipOutputStream
345 Output stream for writing zip files.
347 wxZipOutputStream::PutNextEntry is used to create
348 a new entry in the output zip, then the entry's data is written to the
349 wxZipOutputStream. Another call to PutNextEntry() closes the current
350 entry and begins the next.
356 @ref overview_wxarc "Archive formats such as zip", wxZipEntry, wxZipInputStream
358 class wxZipOutputStream
: public wxArchiveOutputStream
363 Constructor. @c level is the compression level to use.
364 It can be a value between 0 and 9 or -1 to use the default value
365 which currently is equivalent to 6.
367 If the parent stream is passed as a pointer then the new filter stream
368 takes ownership of it. If it is passed by reference then it does not.
370 In a Unicode build the third parameter @c conv is used to translate
371 the filename and comment fields to an 8-bit encoding. It has no effect on the
374 wxZipOutputStream(wxOutputStream
& stream
, int level
= -1,
375 wxMBConv
& conv
= wxConvLocal
);
376 wxZipOutputStream(wxOutputStream
* stream
, int level
= -1,
377 wxMBConv
& conv
= wxConvLocal
);
381 The destructor calls Close() to finish
382 writing the zip if it has not been called already.
384 ~wxZipOutputStream();
387 Finishes writing the zip, returning @true if successful.
388 Called by the destructor if not called explicitly.
393 Close the current entry. It is called implicitly whenever another new
394 entry is created with CopyEntry()
395 or PutNextEntry(), or
396 when the zip is closed.
401 Transfers the zip comment from the wxZipInputStream
402 to this output stream.
404 bool CopyArchiveMetaData(wxZipInputStream
& inputStream
);
407 Takes ownership of @c entry and uses it to create a new entry
408 in the zip. @c entry is then opened in @c inputStream and its contents
409 copied to this stream.
411 CopyEntry() is much more efficient than transferring the data using
412 Read() and Write() since it will copy them without decompressing and
415 For zips on seekable streams, @c entry must be from the same zip file
416 as @c stream. For non-seekable streams, @c entry must also be the
417 last thing read from @c inputStream.
419 bool CopyEntry(wxZipEntry
* entry
, wxZipInputStream
& inputStream
);
423 Set the compression level that will be used the next time an entry is
424 created. It can be a value between 0 and 9 or -1 to use the default value
425 which currently is equivalent to 6.
428 void SetLevel(int level
);
434 Create a new directory entry
435 (see wxArchiveEntry::IsDir)
436 with the given name and timestamp.
439 also be used to create directory entries, by supplying a name with
440 a trailing path separator.
442 bool PutNextDirEntry(const wxString
& name
);
446 , @b off_t@e size = wxInvalidOffset)
448 Create a new entry with the given name, timestamp and size.
450 bool PutNextEntry(wxZipEntry
* entry
);
451 bool PutNextEntry(const wxString
& name
);
455 Sets a comment for the zip as a whole. It is written at the end of the
458 void SetComment(const wxString
& comment
);