]>
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.
70 wxZipEntry
* Clone() const;
74 A short comment for this entry.
76 wxString
GetComment();
77 const 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.
85 The remaining bits can store platform specific permission bits or
86 attributes, and their meaning depends on the value
87 of @ref systemmadeby() SetSystemMadeBy.
88 If IsMadeByUnix() is @true then the
89 high 16 bits are unix mode bits.
90 The following other accessors access these bits:
91 @ref wxArchiveEntry::isreadonly IsReadOnly/SetIsReadOnly
93 @ref wxArchiveEntry::isdir IsDir/SetIsDir
95 @ref mode() Get/SetMode
97 wxUint32
GetExternalAttributes();
98 const void SetExternalAttributes(wxUint32 attr
);
103 The extra field from the entry's central directory record.
104 The extra field is used to store platform or application specific
105 data. See Pkware's document 'appnote.txt' for information on its format.
107 const char* GetExtra();
108 const size_t GetExtraLen();
109 const void SetExtra(const char* extra
, size_t len
);
114 The extra field from the entry's local record.
115 The extra field is used to store platform or application specific
116 data. See Pkware's document 'appnote.txt' for information on its format.
118 const char* GetLocalExtra();
119 const size_t GetLocalExtraLen();
120 const void SetLocalExtra(const char* extra
, size_t len
);
125 The compression method. The enumeration @c wxZipMethod lists the
127 The default constructor sets this to wxZIP_METHOD_DEFAULT,
128 which allows wxZipOutputStream to
129 choose the method when writing the entry.
132 const void SetMethod(int method
);
137 Sets the DOS attributes
138 in @ref externalattributes() GetExternalAttributes
139 to be consistent with the @c mode given.
140 If IsMadeByUnix() is @true then also
141 stores @c mode in GetExternalAttributes().
142 Note that the default constructor
143 sets @ref systemmadeby() GetSystemMadeBy to
144 wxZIP_SYSTEM_MSDOS by default. So to be able to store unix
145 permissions when creating zips, call SetSystemMadeBy(wxZIP_SYSTEM_UNIX).
148 const void SetMode(int mode
);
153 The originating file-system. The default constructor sets this to
154 wxZIP_SYSTEM_MSDOS. Set it to wxZIP_SYSTEM_UNIX in order to be
155 able to store unix permissions using @ref mode() SetMode.
157 int GetSystemMadeBy();
158 const void SetSystemMadeBy(int system
);
162 The compressed size of this entry in bytes.
164 off_t
GetCompressedSize() const;
167 CRC32 for this entry's data.
169 wxUint32
GetCrc() const;
172 Returns a combination of the bits flags in the enumeration @c wxZipFlags.
174 int GetFlags() const;
178 A static member that translates a filename into the internal format used
179 within the archive. If the third parameter is provided, the bool pointed
180 to is set to indicate whether the name looks like a directory name
181 (i.e. has a trailing path separator).
183 @see @ref overview_wxarcbyname "Looking up an archive entry by name"
185 wxString
GetInternalName();
186 const wxString
GetInternalName(const wxString
& name
,
187 wxPathFormat format
= wxPATH_NATIVE
,
188 bool* pIsDir
= NULL
);
192 Returns @true if @ref systemmadeby() GetSystemMadeBy
193 is a flavour of unix.
195 bool IsMadeByUnix() const;
199 Indicates that this entry's data is text in an 8-bit encoding.
202 const void SetIsText(bool isText
= true);
207 Sets the notifier for this entry.
208 Whenever the wxZipInputStream updates
209 this entry, it will then invoke the associated
210 notifier's wxZipNotifier::OnEntryUpdated
212 Setting a notifier is not usually necessary. It is used to handle
213 certain cases when modifying an zip in a pipeline (i.e. between
214 non-seekable streams).
216 @see @ref overview_wxarcnoseek "Archives on non-seekable streams", wxZipNotifier
218 void SetNotifier(wxZipNotifier
& notifier
);
219 void UnsetNotifier();
225 wxZipEntry
& operator operator=(const wxZipEntry
& entry
);
230 @class wxZipInputStream
233 Input stream for reading zip files.
235 wxZipInputStream::GetNextEntry returns an
236 wxZipEntry object containing the meta-data
237 for the next entry in the zip (and gives away ownership). Reading from
238 the wxZipInputStream then returns the entry's data. Eof() becomes @true
239 after an attempt has been made to read past the end of the entry's data.
240 When there are no more entries, GetNextEntry() returns @NULL and sets Eof().
242 Note that in general zip entries are not seekable, and
243 wxZipInputStream::SeekI() always returns wxInvalidOffset.
249 @ref overview_wxarc "Archive formats such as zip", wxZipEntry, wxZipOutputStream
251 class wxZipInputStream
: public wxArchiveInputStream
256 Compatibility constructor (requires WXWIN_COMPATIBILITY_2_6).
257 When this constructor is used, an emulation of seeking is
258 switched on for compatibility with previous versions. Note however,
259 that it is deprecated.
261 wxZipInputStream(wxInputStream
& stream
,
262 wxMBConv
& conv
= wxConvLocal
);
263 wxZipInputStream(wxInputStream
* stream
,
264 wxMBConv
& conv
= wxConvLocal
);
265 wxZipInputStream(const wxString
& archive
,
266 const wxString
& file
);
270 Closes the current entry. On a non-seekable stream reads to the end of
271 the current entry first.
276 Returns the zip comment.
277 This is stored at the end of the zip, therefore when reading a zip
278 from a non-seekable stream, it returns the empty string until the
279 end of the zip has been reached, i.e. when GetNextEntry() returns
282 wxString
GetComment();
285 Closes the current entry if one is open, then reads the meta-data for
286 the next entry and returns it in a wxZipEntry
287 object, giving away ownership. The stream is then open and can be read.
289 wxZipEntry
* GetNextEntry();
292 For a zip on a seekable stream returns the total number of entries in
293 the zip. For zips on non-seekable streams returns the number of entries
294 returned so far by GetNextEntry().
296 int GetTotalEntries();
299 Closes the current entry if one is open, then opens the entry specified
300 by the @a entry object.
301 @a entry should be from the same zip file, and the zip should
302 be on a seekable stream.
304 bool OpenEntry(wxZipEntry
& entry
);
309 @class wxZipClassFactory
312 Class factory for the zip archive format. See the base class
319 @ref overview_wxarc "Archive formats such as zip", @ref overview_wxarcgeneric
320 "Generic archive programming", wxZipEntry, wxZipInputStream, wxZipOutputStream
322 class wxZipClassFactory
: public wxArchiveClassFactory
330 @class wxZipOutputStream
333 Output stream for writing zip files.
335 wxZipOutputStream::PutNextEntry is used to create
336 a new entry in the output zip, then the entry's data is written to the
337 wxZipOutputStream. Another call to PutNextEntry() closes the current
338 entry and begins the next.
344 @ref overview_wxarc "Archive formats such as zip", wxZipEntry, wxZipInputStream
346 class wxZipOutputStream
: public wxArchiveOutputStream
351 Constructor. @c level is the compression level to use.
352 It can be a value between 0 and 9 or -1 to use the default value
353 which currently is equivalent to 6.
354 If the parent stream is passed as a pointer then the new filter stream
355 takes ownership of it. If it is passed by reference then it does not.
356 In a Unicode build the third parameter @c conv is used to translate
357 the filename and comment fields to an 8-bit encoding. It has no effect on the
360 wxZipOutputStream(wxOutputStream
& stream
, int level
= -1,
361 wxMBConv
& conv
= wxConvLocal
);
362 wxZipOutputStream(wxOutputStream
* stream
, int level
= -1,
363 wxMBConv
& conv
= wxConvLocal
);
367 The destructor calls Close() to finish
368 writing the zip if it has not been called already.
370 ~wxZipOutputStream();
373 Finishes writing the zip, returning @true if successful.
374 Called by the destructor if not called explicitly.
379 Close the current entry. It is called implicitly whenever another new
380 entry is created with CopyEntry()
381 or PutNextEntry(), or
382 when the zip is closed.
387 Transfers the zip comment from the wxZipInputStream
388 to this output stream.
390 bool CopyArchiveMetaData(wxZipInputStream
& inputStream
);
393 Takes ownership of @c entry and uses it to create a new entry
394 in the zip. @c entry is then opened in @c inputStream and its contents
395 copied to this stream.
396 CopyEntry() is much more efficient than transferring the data using
397 Read() and Write() since it will copy them without decompressing and
399 For zips on seekable streams, @c entry must be from the same zip file
400 as @c stream. For non-seekable streams, @c entry must also be the
401 last thing read from @c inputStream.
403 bool CopyEntry(wxZipEntry
* entry
, wxZipInputStream
& inputStream
);
407 Set the compression level that will be used the next time an entry is
408 created. It can be a value between 0 and 9 or -1 to use the default value
409 which currently is equivalent to 6.
412 const void SetLevel(int level
);
417 Create a new directory entry
418 (see wxArchiveEntry::IsDir)
419 with the given name and timestamp.
421 also be used to create directory entries, by supplying a name with
422 a trailing path separator.
424 bool PutNextDirEntry(const wxString
& name
);
428 , @b off_t@e size = wxInvalidOffset)
429 Create a new entry with the given name, timestamp and size.
431 bool PutNextEntry(wxZipEntry
* entry
);
432 bool PutNextEntry(const wxString
& name
);
436 Sets a comment for the zip as a whole. It is written at the end of the
439 void SetComment(const wxString
& comment
);