Contents Up Previous Next

wxZipEntry

Holds the meta-data for an entry in a zip.

Derived from

wxArchiveEntry

Include files

<wx/zipstrm.h>

Data structures

Constants for Get/SetMethod:

// 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
};

Constants for Get/SetSystemMadeBy:

// 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
};

Constants for Get/SetExternalAttributes:

// 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
};

Constants for Get/SetFlags:

// 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
};

See also

Archive formats such as zip
wxZipInputStream
wxZipOutputStream
wxZipNotifier

Field availability

When reading a zip from a stream that is seekable, GetNextEntry() returns a fully populated wxZipEntry object except for wxZipEntry::GetLocalExtra(). 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 GetNextEntry() returns:

GetDateTime
GetInternalFormat
GetInternalName
GetFlags
GetLocalExtra
GetMethod
GetName
GetOffset
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:

GetCompressedSize
GetCrc
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:

GetComment
GetExternalAttributes
GetExtra
GetMode
GetSystemMadeBy
IsReadOnly
IsMadeByUnix
IsText

Members

wxZipEntry::wxZipEntry
wxZipEntry::Clone
wxZipEntry::Get/SetComment
wxZipEntry::GetCompressedSize
wxZipEntry::GetCrc
wxZipEntry::Get/SetExternalAttributes
wxZipEntry::Get/SetExtra
wxZipEntry::GetFlags
wxZipEntry::GetInternalName
wxZipEntry::Get/SetLocalExtra
wxZipEntry::Get/SetMethod
wxZipEntry::Get/SetMode
wxZipEntry::SetNotifier
wxZipEntry::Get/SetSystemMadeBy
wxZipEntry::IsMadeByUnix
wxZipEntry::IsText/SetIsText
wxZipEntry::operator=


wxZipEntry::wxZipEntry

wxZipEntry(const wxString& name = wxEmptyString, const wxDateTime& dt = wxDateTime::Now(), off_t size = wxInvalidOffset)

Constructor.

wxZipEntry(const wxZipEntry& entry)

Copy constructor.


wxZipEntry::Clone

wxZipEntry* Clone() const

Make a copy of this entry.


wxZipEntry::Get/SetComment

wxString GetComment() const

void SetComment(const wxString& comment)

A short comment for this entry.


wxZipEntry::GetCompressedSize

off_t GetCompressedSize() const

The compressed size of this entry in bytes.


wxZipEntry::GetCrc

wxUint32 GetCrc() const

CRC32 for this entry's data.


wxZipEntry::Get/SetExternalAttributes

wxUint32 GetExternalAttributes() const

void SetExternalAttributes(wxUint32 attr)

The low 8 bits are always the DOS/Windows file attributes for this entry. The values of these attributes are given in the enumeration wxZipAttributes.

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.

The following other accessors access these bits:

IsReadOnly/SetIsReadOnly
IsDir/SetIsDir
Get/SetMode


wxZipEntry::Get/SetExtra

const char* GetExtra() const

size_t GetExtraLen() const

void SetExtra(const char* extra, size_t len)

The extra field from the entry's central directory record.

The extra field is used to store platform or application specific data. See Pkware's document 'appnote.txt' for information on its format.


wxZipEntry::GetFlags

int GetFlags() const

Returns a combination of the bits flags in the enumeration wxZipFlags.


wxZipEntry::GetInternalName

wxString GetInternalName() const

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.

wxString GetInternalName(const wxString& name, wxPathFormat format = wxPATH_NATIVE, bool* pIsDir = NULL)

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).

See also

Looking up an archive entry by name


wxZipEntry::Get/SetLocalExtra

const char* GetLocalExtra() const

size_t GetLocalExtraLen() const

void SetLocalExtra(const char* extra, size_t len)

The extra field from the entry's local record.

The extra field is used to store platform or application specific data. See Pkware's document 'appnote.txt' for information on its format.


wxZipEntry::Get/SetMethod

int GetMethod() const

void SetMethod(int method)

The compression method. The enumeration wxZipMethod lists the possible values.

The default constructor sets this to wxZIP_METHOD_DEFAULT, which allows wxZipOutputStream to choose the method when writing the entry.


wxZipEntry::Get/SetMode

int GetMode() const

If IsMadeByUnix() is true then returns the unix permission bits stored in GetExternalAttributes(). Otherwise synthesises them from the DOS attributes.

void SetMode(int mode)

Sets the DOS attributes in GetExternalAttributes() to be consistent with the mode given.

If IsMadeByUnix() is true then also stores mode in GetExternalAttributes().

Note that the default constructor sets GetSystemMadeBy() to wxZIP_SYSTEM_MSDOS by default. So to be able to store unix permissions when creating zips, call SetSystemMadeBy(wxZIP_SYSTEM_UNIX).


wxZipEntry::SetNotifier

void SetNotifier(wxZipNotifier& notifier)

void UnsetNotifier()

Sets the notifier for this entry. Whenever the wxZipInputStream updates this entry, it will then invoke the associated notifier's OnEntryUpdated method.

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).

See also

Archives on non-seekable streams
wxZipNotifier


wxZipEntry::Get/SetSystemMadeBy

int GetSystemMadeBy() const

void SetSystemMadeBy(int system)

The originating file-system. The default constructor sets this to wxZIP_SYSTEM_MSDOS. Set it to wxZIP_SYSTEM_UNIX in order to be able to store unix permissions using SetMode().


wxZipEntry::IsMadeByUnix

bool IsMadeByUnix() const

Returns true if GetSystemMadeBy() is a flavour of unix.


wxZipEntry::IsText/SetIsText

bool IsText() const

void SetIsText(bool isText = true)

Indicates that this entry's data is text in an 8-bit encoding.


wxZipEntry::operator=

wxZipEntry& operator operator=(const wxZipEntry& entry)

Assignment operator.