2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: zipstrm.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxZipNotifier
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// Compression Method, only 0 (store) and 8 (deflate) are supported here
|
|
|
|
enum wxZipMethod
|
|
|
|
{
|
|
|
|
wxZIP_METHOD_STORE,
|
|
|
|
wxZIP_METHOD_SHRINK,
|
|
|
|
wxZIP_METHOD_REDUCE1,
|
|
|
|
wxZIP_METHOD_REDUCE2,
|
|
|
|
wxZIP_METHOD_REDUCE3,
|
|
|
|
wxZIP_METHOD_REDUCE4,
|
|
|
|
wxZIP_METHOD_IMPLODE,
|
|
|
|
wxZIP_METHOD_TOKENIZE,
|
|
|
|
wxZIP_METHOD_DEFLATE,
|
|
|
|
wxZIP_METHOD_DEFLATE64,
|
|
|
|
wxZIP_METHOD_BZIP2 = 12,
|
|
|
|
wxZIP_METHOD_DEFAULT = 0xffff
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Originating File-System.
|
|
|
|
///
|
|
|
|
/// These are Pkware's values. Note that Info-zip disagree on some of them,
|
|
|
|
/// most notably NTFS.
|
|
|
|
enum wxZipSystem
|
|
|
|
{
|
|
|
|
wxZIP_SYSTEM_MSDOS,
|
|
|
|
wxZIP_SYSTEM_AMIGA,
|
|
|
|
wxZIP_SYSTEM_OPENVMS,
|
|
|
|
wxZIP_SYSTEM_UNIX,
|
|
|
|
wxZIP_SYSTEM_VM_CMS,
|
|
|
|
wxZIP_SYSTEM_ATARI_ST,
|
|
|
|
wxZIP_SYSTEM_OS2_HPFS,
|
|
|
|
wxZIP_SYSTEM_MACINTOSH,
|
|
|
|
wxZIP_SYSTEM_Z_SYSTEM,
|
|
|
|
wxZIP_SYSTEM_CPM,
|
|
|
|
wxZIP_SYSTEM_WINDOWS_NTFS,
|
|
|
|
wxZIP_SYSTEM_MVS,
|
|
|
|
wxZIP_SYSTEM_VSE,
|
|
|
|
wxZIP_SYSTEM_ACORN_RISC,
|
|
|
|
wxZIP_SYSTEM_VFAT,
|
|
|
|
wxZIP_SYSTEM_ALTERNATE_MVS,
|
|
|
|
wxZIP_SYSTEM_BEOS,
|
|
|
|
wxZIP_SYSTEM_TANDEM,
|
|
|
|
wxZIP_SYSTEM_OS_400
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Dos/Win file attributes
|
|
|
|
enum wxZipAttributes
|
|
|
|
{
|
|
|
|
wxZIP_A_RDONLY = 0x01,
|
|
|
|
wxZIP_A_HIDDEN = 0x02,
|
|
|
|
wxZIP_A_SYSTEM = 0x04,
|
|
|
|
wxZIP_A_SUBDIR = 0x10,
|
|
|
|
wxZIP_A_ARCH = 0x20,
|
|
|
|
|
|
|
|
wxZIP_A_MASK = 0x37
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Values for the flags field in the zip headers
|
|
|
|
enum wxZipFlags
|
|
|
|
{
|
|
|
|
wxZIP_ENCRYPTED = 0x0001,
|
|
|
|
wxZIP_DEFLATE_NORMAL = 0x0000, // normal compression
|
|
|
|
wxZIP_DEFLATE_EXTRA = 0x0002, // extra compression
|
|
|
|
wxZIP_DEFLATE_FAST = 0x0004, // fast compression
|
|
|
|
wxZIP_DEFLATE_SUPERFAST = 0x0006, // superfast compression
|
|
|
|
wxZIP_DEFLATE_MASK = 0x0006,
|
|
|
|
wxZIP_SUMS_FOLLOW = 0x0008, // crc and sizes come after the data
|
|
|
|
wxZIP_ENHANCED = 0x0010,
|
|
|
|
wxZIP_PATCH = 0x0020,
|
|
|
|
wxZIP_STRONG_ENC = 0x0040,
|
|
|
|
wxZIP_UNUSED = 0x0F80,
|
|
|
|
wxZIP_RESERVED = 0xF000
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxZipNotifier
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
If you need to know when a wxZipInputStream updates a wxZipEntry,
|
2008-03-08 13:52:38 +00:00
|
|
|
you can create a notifier by deriving from this abstract base class,
|
2008-09-27 10:27:44 +00:00
|
|
|
overriding wxZipNotifier::OnEntryUpdated().
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
An instance of your notifier class can then be assigned to wxZipEntry
|
2008-09-27 10:27:44 +00:00
|
|
|
objects, using wxZipEntry::SetNotifier().
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Setting a notifier is not usually necessary. It is used to handle
|
|
|
|
certain cases when modifying an zip in a pipeline (i.e. between
|
|
|
|
non-seekable streams).
|
2008-09-27 10:27:44 +00:00
|
|
|
See @ref overview_archive_noseek.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
2008-10-04 11:01:50 +00:00
|
|
|
@category{archive,streams}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
@see @ref overview_archive_noseek, wxZipEntry, wxZipInputStream, wxZipOutputStream
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxZipNotifier
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-09-27 10:27:44 +00:00
|
|
|
Override this to receive notifications when an wxZipEntry object changes.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 12:29:33 +00:00
|
|
|
virtual void OnEntryUpdated(wxZipEntry& entry) = 0;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxZipEntry
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Holds the meta-data for an entry in a zip.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
@section zipentry_avail Field availability
|
|
|
|
|
|
|
|
When reading a zip from a stream that is seekable, wxZipEntry::GetNextEntry()
|
|
|
|
returns a fully populated wxZipEntry object except for wxZipEntry::GetLocalExtra().
|
|
|
|
wxZipEntry::GetLocalExtra() becomes available when the entry is opened, either by
|
|
|
|
calling wxZipInputStream::OpenEntry() or by making an attempt to read the entry's data.
|
|
|
|
|
|
|
|
For zips on non-seekable streams, the following fields are always available
|
|
|
|
when wxZipEntry::GetNextEntry() returns:
|
|
|
|
- wxZipEntry::GetDateTime
|
|
|
|
- wxZipEntry::GetInternalFormat
|
|
|
|
- wxZipEntry::GetInternalName
|
|
|
|
- wxZipEntry::GetFlags
|
|
|
|
- wxZipEntry::GetLocalExtra
|
|
|
|
- wxZipEntry::GetMethod
|
|
|
|
- wxZipEntry::GetName
|
|
|
|
- wxZipEntry::GetOffset
|
|
|
|
- wxZipEntry::IsDir
|
|
|
|
|
|
|
|
The following fields are also usually available when GetNextEntry() returns,
|
|
|
|
however, if the zip was also written to a non-seekable stream the zipper is
|
|
|
|
permitted to store them after the entry's data. In that case they become
|
|
|
|
available when the entry's data has been read to Eof(), or CloseEntry()
|
|
|
|
has been called. (GetFlags() & wxZIP_SUMS_FOLLOW) != 0 indicates that
|
|
|
|
one or more of these come after the data:
|
|
|
|
- wxZipEntry::GetCompressedSize
|
|
|
|
- wxZipEntry::GetCrc
|
|
|
|
- wxZipEntry::GetSize
|
|
|
|
|
|
|
|
The following are stored at the end of the zip, and become available when the
|
|
|
|
end of the zip has been reached, i.e. after GetNextEntry() returns @NULL
|
|
|
|
and Eof() is true:
|
|
|
|
- wxZipEntry::GetComment
|
|
|
|
- wxZipEntry::GetExternalAttributes
|
|
|
|
- wxZipEntry::GetExtra
|
|
|
|
- wxZipEntry::GetMode
|
|
|
|
- wxZipEntry::GetSystemMadeBy
|
|
|
|
- wxZipEntry::IsReadOnly
|
|
|
|
- wxZipEntry::IsMadeByUnix
|
|
|
|
- wxZipEntry::IsText
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
2008-10-04 11:01:50 +00:00
|
|
|
@category{archive,streams}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
@see @ref overview_archive, wxZipInputStream, wxZipOutputStream, wxZipNotifier
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxZipEntry : public wxArchiveEntry
|
|
|
|
{
|
|
|
|
public:
|
2008-09-27 12:29:33 +00:00
|
|
|
wxZipEntry(const wxString& name = wxEmptyString,
|
|
|
|
const wxDateTime& dt = Now(),
|
|
|
|
wxFileOffset size = wxInvalidOffset);
|
2008-09-27 10:27:44 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Copy constructor.
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxZipEntry(const wxZipEntry& entry);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Make a copy of this entry.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxZipEntry* Clone() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:27:44 +00:00
|
|
|
Gets and sets the short comment for this entry.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
wxString GetComment() const;
|
|
|
|
void SetComment(const wxString& comment);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
The low 8 bits are always the DOS/Windows file attributes for this entry.
|
2008-09-27 10:27:44 +00:00
|
|
|
The values of these attributes are given in the enumeration ::wxZipAttributes.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
The remaining bits can store platform specific permission bits or
|
|
|
|
attributes, and their meaning depends on the value of SetSystemMadeBy().
|
|
|
|
If IsMadeByUnix() is @true then the high 16 bits are unix mode bits.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
The following other accessors access these bits:
|
|
|
|
- IsReadOnly() / SetIsReadOnly()
|
|
|
|
- IsDir() / SetIsDir()
|
|
|
|
- GetMode() / SetMode()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
wxUint32 GetExternalAttributes() const;
|
|
|
|
void SetExternalAttributes(wxUint32 attr);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
The extra field from the entry's central directory record.
|
2008-09-27 10:27:44 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The extra field is used to store platform or application specific
|
|
|
|
data. See Pkware's document 'appnote.txt' for information on its format.
|
|
|
|
*/
|
2009-01-10 22:42:09 +00:00
|
|
|
const char* GetExtra() const;
|
2008-09-27 10:27:44 +00:00
|
|
|
size_t GetExtraLen() const;
|
|
|
|
void SetExtra(const char* extra, size_t len);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
The extra field from the entry's local record.
|
2008-09-27 10:27:44 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The extra field is used to store platform or application specific
|
|
|
|
data. See Pkware's document 'appnote.txt' for information on its format.
|
|
|
|
*/
|
2009-01-10 22:42:09 +00:00
|
|
|
const char* GetLocalExtra() const;
|
2008-09-27 10:27:44 +00:00
|
|
|
size_t GetLocalExtraLen() const;
|
|
|
|
void SetLocalExtra(const char* extra, size_t len);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:27:44 +00:00
|
|
|
The compression method.
|
|
|
|
The enumeration ::wxZipMethod lists the possible values.
|
|
|
|
|
|
|
|
The default constructor sets this to @c wxZIP_METHOD_DEFAULT,
|
|
|
|
which allows wxZipOutputStream to choose the method when writing the entry.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
int GetMethod() const;
|
|
|
|
void SetMethod(int method);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:27:44 +00:00
|
|
|
If IsMadeByUnix() is true then returns the unix permission bits stored
|
|
|
|
in GetExternalAttributes(). Otherwise synthesises them from the DOS attributes.
|
|
|
|
*/
|
|
|
|
int GetMode() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the DOS attributes in GetExternalAttributes() to be consistent with
|
|
|
|
the @a mode given.
|
|
|
|
|
|
|
|
If IsMadeByUnix() is @true then also stores @a mode in GetExternalAttributes().
|
|
|
|
Note that the default constructor sets GetSystemMadeBy() to
|
|
|
|
@c wxZIP_SYSTEM_MSDOS by default. So to be able to store unix
|
2008-03-08 13:52:38 +00:00
|
|
|
permissions when creating zips, call SetSystemMadeBy(wxZIP_SYSTEM_UNIX).
|
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
void SetMode(int mode);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:27:44 +00:00
|
|
|
The originating file-system.
|
|
|
|
|
|
|
|
The default constructor sets this to @c wxZIP_SYSTEM_MSDOS.
|
|
|
|
Set it to @c wxZIP_SYSTEM_UNIX in order to be able to store unix
|
|
|
|
permissions using SetMode().
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
int GetSystemMadeBy() const;
|
|
|
|
void SetSystemMadeBy(int system);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
The compressed size of this entry in bytes.
|
|
|
|
*/
|
2008-09-27 12:29:33 +00:00
|
|
|
wxFileOffset GetCompressedSize() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
CRC32 for this entry's data.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxUint32 GetCrc() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a combination of the bits flags in the enumeration @c wxZipFlags.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetFlags() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
A static member that translates a filename into the internal format used
|
|
|
|
within the archive. If the third parameter is provided, the bool pointed
|
|
|
|
to is set to indicate whether the name looks like a directory name
|
|
|
|
(i.e. has a trailing path separator).
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
@see @ref overview_archive_byname
|
|
|
|
*/
|
|
|
|
wxString GetInternalName(const wxString& name,
|
|
|
|
wxPathFormat format = wxPATH_NATIVE,
|
|
|
|
bool* pIsDir = NULL);
|
|
|
|
/**
|
|
|
|
Returns the entry's filename in the internal format used within the archive.
|
|
|
|
The name can include directory components, i.e. it can be a full path.
|
|
|
|
|
|
|
|
The names of directory entries are returned without any trailing path separator.
|
|
|
|
This gives a canonical name that can be used in comparisons.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
wxString GetInternalName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-09-27 10:27:44 +00:00
|
|
|
Returns @true if GetSystemMadeBy() is a flavour of unix.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsMadeByUnix() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Indicates that this entry's data is text in an 8-bit encoding.
|
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
bool IsText() const;
|
|
|
|
void SetIsText(bool isText = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:27:44 +00:00
|
|
|
Sets the notifier (see wxZipNotifier) for this entry.
|
|
|
|
Whenever the wxZipInputStream updates this entry, it will then invoke
|
|
|
|
the associated notifier's wxZipNotifier::OnEntryUpdated() method.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Setting a notifier is not usually necessary. It is used to handle
|
|
|
|
certain cases when modifying an zip in a pipeline (i.e. between
|
|
|
|
non-seekable streams).
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-09-27 10:27:44 +00:00
|
|
|
@see @ref overview_archive_noseek, wxZipNotifier
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetNotifier(wxZipNotifier& notifier);
|
2008-03-08 14:43:31 +00:00
|
|
|
void UnsetNotifier();
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Assignment operator.
|
|
|
|
*/
|
2008-09-27 10:27:44 +00:00
|
|
|
wxZipEntry& operator=(const wxZipEntry& entry);
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxZipInputStream
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Input stream for reading zip files.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:59:01 +00:00
|
|
|
wxZipInputStream::GetNextEntry() returns a wxZipEntry object containing the
|
|
|
|
meta-data for the next entry in the zip (and gives away ownership).
|
|
|
|
Reading from the wxZipInputStream then returns the entry's data.
|
|
|
|
Eof() becomes @true after an attempt has been made to read past the end of
|
|
|
|
the entry's data.
|
2008-03-08 13:52:38 +00:00
|
|
|
When there are no more entries, GetNextEntry() returns @NULL and sets Eof().
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Note that in general zip entries are not seekable, and
|
2008-09-27 10:59:01 +00:00
|
|
|
wxZipInputStream::SeekI() always returns ::wxInvalidOffset.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
2008-10-04 11:01:50 +00:00
|
|
|
@category{archive,streams}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:59:01 +00:00
|
|
|
@see @ref overview_archive, wxZipEntry, wxZipOutputStream
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxZipInputStream : public wxArchiveInputStream
|
|
|
|
{
|
|
|
|
public:
|
2008-09-27 10:59:01 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Constructor. In a Unicode build the second parameter @a conv is used to
|
|
|
|
translate the filename and comment fields into Unicode.
|
|
|
|
It has no effect on the stream's data.
|
|
|
|
If the parent stream is passed as a pointer then the new filter stream
|
|
|
|
takes ownership of it. If it is passed by reference then it does not.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxZipInputStream(wxInputStream& stream,
|
|
|
|
wxMBConv& conv = wxConvLocal);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxZipInputStream(wxInputStream* stream,
|
|
|
|
wxMBConv& conv = wxConvLocal);
|
2008-09-27 10:59:01 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@deprecated
|
|
|
|
Compatibility constructor (requires WXWIN_COMPATIBILITY_2_6).
|
|
|
|
When this constructor is used, an emulation of seeking is
|
|
|
|
switched on for compatibility with previous versions. Note however,
|
|
|
|
that it is deprecated.
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxZipInputStream(const wxString& archive,
|
|
|
|
const wxString& file);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Closes the current entry.
|
|
|
|
On a non-seekable stream reads to the end of the current entry first.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool CloseEntry();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the zip comment.
|
2008-09-27 10:59:01 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This is stored at the end of the zip, therefore when reading a zip
|
2008-09-27 10:59:01 +00:00
|
|
|
from a non-seekable stream, it returns the empty string until the end
|
|
|
|
of the zip has been reached, i.e. when GetNextEntry() returns @NULL.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxString GetComment();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Closes the current entry if one is open, then reads the meta-data for
|
2008-09-27 10:59:01 +00:00
|
|
|
the next entry and returns it in a wxZipEntry object, giving away ownership.
|
|
|
|
The stream is then open and can be read.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxZipEntry* GetNextEntry();
|
|
|
|
|
|
|
|
/**
|
|
|
|
For a zip on a seekable stream returns the total number of entries in
|
|
|
|
the zip. For zips on non-seekable streams returns the number of entries
|
|
|
|
returned so far by GetNextEntry().
|
|
|
|
*/
|
|
|
|
int GetTotalEntries();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Closes the current entry if one is open, then opens the entry specified
|
2008-03-09 12:33:59 +00:00
|
|
|
by the @a entry object.
|
2008-09-27 10:59:01 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@a entry should be from the same zip file, and the zip should
|
2008-03-08 13:52:38 +00:00
|
|
|
be on a seekable stream.
|
2008-09-27 10:59:01 +00:00
|
|
|
|
|
|
|
@see overview_archive_byname
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool OpenEntry(wxZipEntry& entry);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxZipClassFactory
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:59:01 +00:00
|
|
|
Class factory for the zip archive format.
|
|
|
|
See the base class for details.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
2008-10-04 11:01:50 +00:00
|
|
|
@category{archive,streams}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:59:01 +00:00
|
|
|
@see @ref overview_archive,
|
|
|
|
@ref overview_archive_generic,
|
|
|
|
wxZipEntry, wxZipInputStream, wxZipOutputStream
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxZipClassFactory : public wxArchiveClassFactory
|
|
|
|
{
|
|
|
|
public:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxZipOutputStream
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Output stream for writing zip files.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:59:01 +00:00
|
|
|
wxZipOutputStream::PutNextEntry() is used to create a new entry in the
|
|
|
|
output zip, then the entry's data is written to the wxZipOutputStream.
|
|
|
|
Another call to wxZipOutputStream::PutNextEntry() closes the current
|
2008-03-08 13:52:38 +00:00
|
|
|
entry and begins the next.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
2008-10-04 11:01:50 +00:00
|
|
|
@category{archive,streams}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-27 10:59:01 +00:00
|
|
|
@see @ref overview_archive, wxZipEntry, wxZipInputStream
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxZipOutputStream : public wxArchiveOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
@a level is the compression level to use.
|
2008-03-08 13:52:38 +00:00
|
|
|
It can be a value between 0 and 9 or -1 to use the default value
|
|
|
|
which currently is equivalent to 6.
|
2008-09-27 10:59:01 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
If the parent stream is passed as a pointer then the new filter stream
|
|
|
|
takes ownership of it. If it is passed by reference then it does not.
|
2008-09-27 10:59:01 +00:00
|
|
|
In a Unicode build the third parameter @a conv is used to translate
|
|
|
|
the filename and comment fields to an 8-bit encoding.
|
|
|
|
It has no effect on the stream's data.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxZipOutputStream(wxOutputStream& stream, int level = -1,
|
|
|
|
wxMBConv& conv = wxConvLocal);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxZipOutputStream(wxOutputStream* stream, int level = -1,
|
|
|
|
wxMBConv& conv = wxConvLocal);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
The destructor calls Close() to finish writing the zip if it has
|
|
|
|
not been called already.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual ~wxZipOutputStream();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Finishes writing the zip, returning @true if successful.
|
|
|
|
Called by the destructor if not called explicitly.
|
|
|
|
*/
|
|
|
|
bool Close();
|
|
|
|
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Close the current entry.
|
|
|
|
It is called implicitly whenever another new entry is created with CopyEntry()
|
|
|
|
or PutNextEntry(), or when the zip is closed.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool CloseEntry();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Transfers the zip comment from the wxZipInputStream
|
|
|
|
to this output stream.
|
|
|
|
*/
|
|
|
|
bool CopyArchiveMetaData(wxZipInputStream& inputStream);
|
|
|
|
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Takes ownership of @a entry and uses it to create a new entry
|
|
|
|
in the zip. @a entry is then opened in @a inputStream and its contents
|
2008-03-08 13:52:38 +00:00
|
|
|
copied to this stream.
|
2008-09-27 10:59:01 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
CopyEntry() is much more efficient than transferring the data using
|
|
|
|
Read() and Write() since it will copy them without decompressing and
|
|
|
|
recompressing them.
|
2008-09-27 10:59:01 +00:00
|
|
|
|
|
|
|
For zips on seekable streams, @a entry must be from the same zip file
|
|
|
|
as @a inputStream. For non-seekable streams, @a entry must also be the
|
|
|
|
last thing read from @a inputStream.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool CopyEntry(wxZipEntry* entry, wxZipInputStream& inputStream);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Set the compression level that will be used the next time an entry is
|
2008-09-27 10:59:01 +00:00
|
|
|
created.
|
|
|
|
|
|
|
|
It can be a value between 0 and 9 or -1 to use the default value
|
2008-03-08 13:52:38 +00:00
|
|
|
which currently is equivalent to 6.
|
|
|
|
*/
|
2008-09-27 10:59:01 +00:00
|
|
|
int GetLevel() const;
|
|
|
|
void SetLevel(int level);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Create a new directory entry (see wxArchiveEntry::IsDir) with the given
|
|
|
|
name and timestamp.
|
|
|
|
|
|
|
|
PutNextEntry() can also be used to create directory entries, by supplying
|
|
|
|
a name with a trailing path separator.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 10:59:01 +00:00
|
|
|
bool PutNextDirEntry(const wxString& name,
|
|
|
|
const wxDateTime& dt = wxDateTime::Now());
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Takes ownership of @a entry and uses it to create a new entry in the zip.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool PutNextEntry(wxZipEntry* entry);
|
2008-09-27 10:59:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a new entry with the given name, timestamp and size.
|
|
|
|
*/
|
|
|
|
bool PutNextEntry(const wxString& name,
|
|
|
|
const wxDateTime& dt = wxDateTime::Now(),
|
2008-09-27 12:29:33 +00:00
|
|
|
wxFileOffset size = wxInvalidOffset);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-09-27 10:59:01 +00:00
|
|
|
Sets a comment for the zip as a whole.
|
|
|
|
It is written at the end of the zip.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetComment(const wxString& comment);
|
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|