diff options
Diffstat (limited to 'zip/ZipArchive/ZipExtraField.cpp')
| -rw-r--r-- | zip/ZipArchive/ZipExtraField.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/zip/ZipArchive/ZipExtraField.cpp b/zip/ZipArchive/ZipExtraField.cpp index 4488e37..f287885 100644 --- a/zip/ZipArchive/ZipExtraField.cpp +++ b/zip/ZipArchive/ZipExtraField.cpp @@ -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,11 +9,12 @@ //
// For the licensing details refer to the License.txt file.
//
-// Web Site: http://www.artpol-software.com
+// Web Site: https://www.artpol-software.com
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ZipExtraField.h"
+CZipArray<WORD> CZipExtraField::m_aNoSizeExtraHeadersID;
bool CZipExtraField::Read(CZipStorage *pStorage, WORD uSize)
{
@@ -25,7 +26,7 @@ bool CZipExtraField::Read(CZipStorage *pStorage, WORD uSize) pStorage->Read(buffer, uSize, true);
char* position = (char*) buffer;
do
- {
+ {
CZipExtraData* pExtra = new CZipExtraData();
if (!pExtra->Read(position, uSize))
{
@@ -48,7 +49,9 @@ void CZipExtraField::Write(char* buffer)const {
int offset = 0;
for (int i = 0; i < GetCount(); i++)
+ {
offset += GetAt(i)->Write(buffer + offset);
+ }
}
int CZipExtraField::GetTotalSize()const
@@ -64,12 +67,37 @@ void CZipExtraField::RemoveInternalHeaders() for (int i = GetCount() - 1; i >= 0; i--)
{
WORD headerID = GetAt(i)->GetHeaderID();
- if (
- headerID == ZIP_EXTRA_ZARCH_NAME)
+ if (headerID == ZIP_EXTRA_PKZIP
+ || headerID == ZIP_EXTRA_WINZIP_AES
+ || headerID == ZIP_EXTRA_UNICODE_PATH
+ || headerID == ZIP_EXTRA_UNICODE_COMMENT
+ || headerID == ZIP_EXTRA_ZARCH_NAME
+ || headerID == ZIP_EXTRA_NTFS)
+ RemoveAt(i);
+ }
+}
+
+void CZipExtraField::RemoveInternalLocalHeaders()
+{
+ for (int i = GetCount() - 1; i >= 0; i--)
+ {
+ WORD headerID = GetAt(i)->GetHeaderID();
+ if (headerID == ZIP_EXTRA_WINZIP_AES
+ || headerID == ZIP_EXTRA_UNICODE_PATH
+ || headerID == ZIP_EXTRA_UNICODE_COMMENT)
RemoveAt(i);
}
}
+void CZipExtraField::Remove(WORD headerID)
+{
+ for (int i = GetCount() - 1; i >= 0; i--)
+ {
+ if (headerID == GetAt(i)->GetHeaderID())
+ RemoveAt(i);
+ }
+}
+
CZipExtraData* CZipExtraField::Lookup(WORD headerID, int& index) const
{
// we can do a non-efficient search here
|
