From 02d6107c97b48888362e7c6a70dcac323c89d741 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 17 Dec 2023 21:23:58 +0100 Subject: ZipArchive: Update to the 4.6.9 release --- zip/ZipArchive/ZipExtraField.cpp | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'zip/ZipArchive/ZipExtraField.cpp') 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 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 -- cgit v1.2.3