summaryrefslogtreecommitdiff
path: root/zip/ZipArchive/ZipExtraField.h
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2023-12-17 21:23:58 +0100
committerTomas Bzatek <tbzatek@redhat.com>2023-12-17 21:23:58 +0100
commit02d6107c97b48888362e7c6a70dcac323c89d741 (patch)
tree5069a77adaf73f7249ac79b6c49a47168a647ef8 /zip/ZipArchive/ZipExtraField.h
parent4e17c2527b106f1b493a3ac77c89858d14f834e2 (diff)
downloadtuxcmd-modules-02d6107c97b48888362e7c6a70dcac323c89d741.tar.xz
ZipArchive: Update to the 4.6.9 release
Diffstat (limited to 'zip/ZipArchive/ZipExtraField.h')
-rw-r--r--zip/ZipArchive/ZipExtraField.h105
1 files changed, 88 insertions, 17 deletions
diff --git a/zip/ZipArchive/ZipExtraField.h b/zip/ZipArchive/ZipExtraField.h
index b857a48..9ea200b 100644
--- a/zip/ZipArchive/ZipExtraField.h
+++ b/zip/ZipArchive/ZipExtraField.h
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
-// This source file is part of the ZipArchive library source distribution and
-// is Copyrighted 2000 - 2007 by Artpol Software - Tadeusz Dracz
+// This source file is part of the ZipArchive Library Open Source distribution
+// and is Copyrighted 2000 - 2022 by Artpol Software - Tadeusz Dracz
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -9,7 +9,7 @@
//
// For the licensing details refer to the License.txt file.
//
-// Web Site: http://www.artpol-software.com
+// Web Site: https://www.artpol-software.com
////////////////////////////////////////////////////////////////////////////////
/**
@@ -30,11 +30,19 @@
#include "ZipCollections.h"
#include "ZipStorage.h"
+#define ZIP_EXTRA_PKZIP 0x0001
+
+#define ZIP_EXTRA_NTFS 0x000A
#define ZIP_EXTRA_ZARCH_NAME 0x5A4C // ZL - ZipArchive Library
#define ZIP_EXTRA_ZARCH_SEEK 0x5A4D
+#define ZIP_EXTRA_WINZIP_AES 0x9901
+
+#define ZIP_EXTRA_UNICODE_PATH 0x7075
+#define ZIP_EXTRA_UNICODE_COMMENT 0x6375
+
#if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
#pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
@@ -53,7 +61,9 @@ class ZIP_API CZipExtraField
{
friend class CZipFileHeader;
public:
- CZipExtraField(){}
+ CZipExtraField()
+ {
+ }
CZipExtraField(const CZipExtraField& arr)
{
*this = arr;
@@ -67,7 +77,7 @@ public:
}
/**
- Gets the total size, the extra data will occupy in the archive.
+ Returns the total size the extra data will occupy in the archive.
\return
The size in bytes.
@@ -82,11 +92,11 @@ public:
*/
bool Validate() const
{
- return GetTotalSize() <= USHRT_MAX;
+ return GetTotalSize() <= (int)USHRT_MAX;
}
/**
- Gets the number of extra data records included in the extra field.
+ Returns the number of extra data records included in the extra field.
\return
The number of extra fields included.
@@ -97,7 +107,7 @@ public:
}
/**
- Gets the extra data record at the given index.
+ Returns the extra data record at the given index.
\param index
The index of extra data record to retrieve.
@@ -143,16 +153,19 @@ public:
\param headerID
The extra data ID.
+ \param bAppend
+ If \c true, add the header at the end of the collection; otherwise add the header at the beginning of the collection
+
\return
The created extra data record.
\see
CZipExtraData::GetHeaderID
*/
- CZipExtraData* CreateNew(WORD headerID)
+ CZipExtraData* CreateNew(WORD headerID, bool bAppend = true)
{
int temp;
- return CreateNew(headerID, temp);
+ return CreateNew(headerID, temp, bAppend);
}
/**
@@ -166,30 +179,54 @@ public:
Receives the value of the index of the new
extra data in the internal collection.
+ \param bAppend
+ If \c true, add the header at the end of the collection; otherwise add the header at the beginning of the collection
+
\return
The created extra data record.
\see
CZipExtraData::GetHeaderID
*/
- CZipExtraData* CreateNew(WORD headerID, int& idx)
+ CZipExtraData* CreateNew(WORD headerID, int& idx, bool bAppend = true)
{
CZipExtraData* pData = new CZipExtraData(headerID);
- idx = (int)m_aData.Add(pData);
+ pData->m_bHasSize = HasSize(headerID);
+ if (bAppend)
+ idx = (int)m_aData.Add(pData);
+ else
+ {
+ idx = 0;
+ m_aData.InsertAt(0, pData);
+ }
return pData;
}
/**
- Removes all extra data records from the extra field,
+ Removes all extra data records from the central extra field
that are internally used by the ZipArchive Library.
*/
void RemoveInternalHeaders();
/**
- Lookups the extra field for the extra data record with the given ID.
+ Removes all extra data records from the local extra field
+ that are internally used by the ZipArchive Library.
+ */
+ void RemoveInternalLocalHeaders();
+
+ /**
+ Removes the extra data with the given ID.
\param headerID
- The ID of the extra data to lookup.
+ The ID of the extra data to remove.
+ */
+ void Remove(WORD headerID);
+
+ /**
+ Searches the extra field for the extra data record with the given ID.
+
+ \param headerID
+ The ID of the extra data to search.
\return
The found extra data record or \c NULL, if the extra data could not be found.
@@ -215,10 +252,10 @@ public:
}
/**
- Lookups the extra field for the extra data record with the given ID.
+ Searches the extra field for the extra data record with the given ID.
\param headerID
- The ID of the extra data to lookup.
+ The ID of the extra data to search.
\param index
Receives the value of the index of the found
@@ -232,6 +269,38 @@ public:
{
Clear();
}
+
+ /**
+ An array of headers that do not write extra data size.
+
+ \see
+ <a href="kb">0610242300|read</a>
+ */
+ static CZipArray<WORD> m_aNoSizeExtraHeadersID;
+
+ /**
+ Returns the value indicating whether the extra data record with the given ID writes its size.
+
+ \param headerID
+ The ID of extra data to examine.
+
+ \return
+ \c true, if the extra data record writes its size; \c false otherwise.
+
+ \see
+ m_aNoSizeExtraHeadersID
+ */
+ static bool HasSize(WORD headerID)
+ {
+ ZIP_ARRAY_SIZE_TYPE size = m_aNoSizeExtraHeadersID.GetSize();
+ for (ZIP_ARRAY_SIZE_TYPE i = 0; i < size; i++)
+ {
+ if (m_aNoSizeExtraHeadersID.GetAt(i) == headerID)
+ return false;
+ }
+ return true;
+ }
+
protected:
/**
@@ -265,7 +334,9 @@ protected:
The buffer to write to.
*/
void Write(char* buffer) const;
+
private:
+
CZipArray<CZipExtraData*> m_aData;
};