summaryrefslogtreecommitdiff
path: root/zip/ZipArchive/ZipExtraData.h
diff options
context:
space:
mode:
Diffstat (limited to 'zip/ZipArchive/ZipExtraData.h')
-rw-r--r--zip/ZipArchive/ZipExtraData.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/zip/ZipArchive/ZipExtraData.h b/zip/ZipArchive/ZipExtraData.h
index cb9c256..b1933bc 100644
--- a/zip/ZipArchive/ZipExtraData.h
+++ b/zip/ZipArchive/ZipExtraData.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
////////////////////////////////////////////////////////////////////////////////
/**
@@ -29,6 +29,9 @@
#include "ZipAutoBuffer.h"
#include "ZipExtraField.h"
#include "memory.h"
+#ifdef __ANDROID__
+#include "string.h"
+#endif
/**
Represents a single data record in an extra field.
@@ -46,11 +49,21 @@ public:
*/
CZipAutoBuffer m_data;
+ /**
+ If \c true, the size of the extra data record is read from the archive and written to it.
+ This is default behavior consistent with the common ZIP format.
+ If \c false, the size is not read or written.
+ You should change this value only when you need special handling.
+ */
+ bool m_bHasSize;
+
CZipExtraData()
{
m_uHeaderID = 0;
+ m_bHasSize = true;
}
+#pragma warning(suppress: 26495)
CZipExtraData(const CZipExtraData& extra)
{
*this = extra;
@@ -65,6 +78,7 @@ public:
CZipExtraData(WORD uHeaderID)
{
m_uHeaderID = uHeaderID;
+ m_bHasSize = true;
}
CZipExtraData& operator=(const CZipExtraData& extra)
@@ -72,6 +86,7 @@ public:
m_uHeaderID = extra.m_uHeaderID;
DWORD uSize = extra.m_data.GetSize();
m_data.Allocate(uSize);
+ m_bHasSize = extra.m_bHasSize;
if (uSize > 0)
memcpy(m_data, extra.m_data, uSize);
return *this;
@@ -103,18 +118,18 @@ 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.
*/
int GetTotalSize() const
{
- return 4 + m_data.GetSize();
+ return (m_bHasSize ? 4 : 2) + m_data.GetSize();
}
/**
- Gets the data ID.
+ Returns the data ID.
\return
The data ID.
@@ -151,7 +166,7 @@ protected:
*/
WORD Write(char* buffer)const;
-private:
+private:
WORD m_uHeaderID;
};