Fix ZIP64 creation with individual files larger 4GB
If single files larger than 4GB where added the recorded file sizes in the local file header where not updated correctly. Additionally recorded file sizes in the central directory where in the wrong order making it impossible to extract. To enable adding files with unknown size which might be larger than 4GB the new method wxZipOutputStream::SetFormat() is added. Additionally a check has been added in case a file larger 4GB has been written without ZIP64 info.
This commit is contained in:
@@ -110,6 +110,14 @@ enum wxZipFlags
|
||||
wxZIP_RESERVED = 0xF000
|
||||
};
|
||||
|
||||
enum wxZipArchiveFormat
|
||||
{
|
||||
/// Default zip format
|
||||
wxZIP_FORMAT_DEFAULT,
|
||||
/// ZIP64 format
|
||||
wxZIP_FORMAT_ZIP64
|
||||
};
|
||||
|
||||
// Forward decls
|
||||
//
|
||||
class WXDLLIMPEXP_FWD_BASE wxZipEntry;
|
||||
@@ -131,6 +139,8 @@ public:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Zip Entry - holds the meta data for a file in the zip
|
||||
|
||||
class wxDataOutputStream;
|
||||
|
||||
class WXDLLIMPEXP_BASE wxZipEntry : public wxArchiveEntry
|
||||
{
|
||||
public:
|
||||
@@ -225,7 +235,7 @@ private:
|
||||
wxArchiveEntry* DoClone() const wxOVERRIDE { return ZipClone(); }
|
||||
|
||||
size_t ReadLocal(wxInputStream& stream, wxMBConv& conv);
|
||||
size_t WriteLocal(wxOutputStream& stream, wxMBConv& conv) const;
|
||||
size_t WriteLocal(wxOutputStream& stream, wxMBConv& conv, wxZipArchiveFormat zipFormat);
|
||||
|
||||
size_t ReadCentral(wxInputStream& stream, wxMBConv& conv);
|
||||
size_t WriteCentral(wxOutputStream& stream, wxMBConv& conv) const;
|
||||
@@ -234,6 +244,9 @@ private:
|
||||
size_t WriteDescriptor(wxOutputStream& stream, wxUint32 crc,
|
||||
wxFileOffset compressedSize, wxFileOffset size);
|
||||
|
||||
void WriteLocalFileSizes(wxDataOutputStream& ds) const;
|
||||
void WriteLocalZip64ExtraInfo(wxOutputStream& stream) const;
|
||||
|
||||
bool LoadExtraInfo(const char* extraData, wxUint16 extraLen, bool localInfo);
|
||||
|
||||
wxUint16 GetInternalFlags(bool checkForUTF8) const;
|
||||
@@ -256,6 +269,7 @@ private:
|
||||
wxUint16 m_DiskStart; // for multidisk archives, not unsupported
|
||||
wxUint16 m_InternalAttributes; // bit 0 set for text files
|
||||
wxUint32 m_ExternalAttributes; // system specific depends on SystemMadeBy
|
||||
wxUint16 m_z64infoOffset; // Offset of ZIP64 local extra data for file sizes
|
||||
|
||||
class wxZipMemory *m_Extra;
|
||||
class wxZipMemory *m_LocalExtra;
|
||||
@@ -307,6 +321,9 @@ public:
|
||||
int GetLevel() const { return m_level; }
|
||||
void WXZIPFIX SetLevel(int level);
|
||||
|
||||
void SetFormat(wxZipArchiveFormat format) { m_format = format; };
|
||||
wxZipArchiveFormat GetFormat() const { return m_format; };
|
||||
|
||||
protected:
|
||||
virtual size_t WXZIPFIX OnSysWrite(const void *buffer, size_t size) wxOVERRIDE;
|
||||
virtual wxFileOffset OnSysTell() const wxOVERRIDE { return m_entrySize; }
|
||||
@@ -351,6 +368,7 @@ private:
|
||||
wxFileOffset m_offsetAdjustment;
|
||||
wxString m_Comment;
|
||||
bool m_endrecWritten;
|
||||
wxZipArchiveFormat m_format;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxZipOutputStream);
|
||||
};
|
||||
|
Reference in New Issue
Block a user