* contrib/hbziparch/_features.h
* contrib/hbziparch/_platform.h
* contrib/hbziparch/Aes.cpp
* contrib/hbziparch/Aes.h
* contrib/hbziparch/BaseLibCompressor.cpp
* contrib/hbziparch/BaseLibCompressor.h
* contrib/hbziparch/BytesWriter.h
* contrib/hbziparch/Bzip2Compressor.cpp
* contrib/hbziparch/Bzip2Compressor.h
* contrib/hbziparch/DeflateCompressor.cpp
* contrib/hbziparch/DeflateCompressor.h
* contrib/hbziparch/DirEnumerator.cpp
* contrib/hbziparch/DirEnumerator.h
* contrib/hbziparch/FileFilter.cpp
* contrib/hbziparch/FileFilter.h
* contrib/hbziparch/FileInfo.h
* contrib/hbziparch/Hmac.cpp
* contrib/hbziparch/Hmac.h
* contrib/hbziparch/RandomPool.cpp
* contrib/hbziparch/RandomPool.h
* contrib/hbziparch/Sha1.cpp
* contrib/hbziparch/Sha1.h
* contrib/hbziparch/std_mfc.h
* contrib/hbziparch/std_stl.h
* contrib/hbziparch/Wildcard.cpp
* contrib/hbziparch/Wildcard.h
* contrib/hbziparch/ZipAbstractFile.h
* contrib/hbziparch/ZipAesCryptograph.cpp
* contrib/hbziparch/ZipAesCryptograph.h
* contrib/hbziparch/ZipArchive.cpp
* contrib/hbziparch/ZipArchive.h
* contrib/hbziparch/ZipAutoBuffer.cpp
* contrib/hbziparch/ZipAutoBuffer.h
* contrib/hbziparch/ZipBaseException.h
* contrib/hbziparch/ZipCallback.h
* contrib/hbziparch/ZipCallbackProvider.h
* contrib/hbziparch/ZipCentralDir.cpp
* contrib/hbziparch/ZipCentralDir.h
* contrib/hbziparch/ZipCollections.h
* contrib/hbziparch/ZipCollections_mfc.h
* contrib/hbziparch/ZipCollections_stl.h
* contrib/hbziparch/ZipCompatibility.cpp
* contrib/hbziparch/ZipCompatibility.h
* contrib/hbziparch/ZipCompressor.cpp
* contrib/hbziparch/ZipCompressor.h
* contrib/hbziparch/ZipCrc32Cryptograph.cpp
* contrib/hbziparch/ZipCrc32Cryptograph.h
* contrib/hbziparch/ZipCryptograph.cpp
* contrib/hbziparch/ZipCryptograph.h
* contrib/hbziparch/ZipException.cpp
* contrib/hbziparch/ZipException.h
* contrib/hbziparch/ZipExtraData.cpp
* contrib/hbziparch/ZipExtraData.h
* contrib/hbziparch/ZipExtraField.cpp
* contrib/hbziparch/ZipExtraField.h
* contrib/hbziparch/ZipFile.h
* contrib/hbziparch/ZipFile_mfc.cpp
* contrib/hbziparch/ZipFile_mfc.h
* contrib/hbziparch/ZipFile_stl.cpp
* contrib/hbziparch/ZipFile_stl.h
* contrib/hbziparch/ZipFileHeader.cpp
* contrib/hbziparch/ZipFileHeader.h
* contrib/hbziparch/ZipFileMapping.h
* contrib/hbziparch/ZipFileMapping_lnx.h
* contrib/hbziparch/ZipFileMapping_win.h
* contrib/hbziparch/ZipMemFile.cpp
* contrib/hbziparch/ZipMemFile.h
* contrib/hbziparch/ZipMutex.h
* contrib/hbziparch/ZipMutex_lnx.h
* contrib/hbziparch/ZipMutex_win.h
* contrib/hbziparch/ZipPathComponent.h
* contrib/hbziparch/ZipPlatform.h
* contrib/hbziparch/ZipPlatformComm.cpp
* contrib/hbziparch/ZipStorage.cpp
* contrib/hbziparch/ZipStorage.h
* contrib/hbziparch/ZipString.h
* contrib/hbziparch/ZipString_mfc.h
* contrib/hbziparch/ZipString_stl.h
* contrib/hbziparch/ZipStringStoreSettings.h
+ ZipArchive lib update finished.
; Pass 2/2
; Please test.
274 lines
5.6 KiB
C++
274 lines
5.6 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// This source file is part of the ZipArchive library source distribution and
|
|
// is Copyrighted 2000 - 2007 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
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// For the licensing details refer to the License.txt file.
|
|
//
|
|
// Web Site: http://www.artpol-software.com
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
* \file ZipExtraField.h
|
|
* Includes the CZipExtraField class.
|
|
*
|
|
*/
|
|
|
|
#if !defined(ZIPARCHIVE_ZIPEXTRAFIELD_DOT_H)
|
|
#define ZIPARCHIVE_ZIPEXTRAFIELD_DOT_H
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif
|
|
|
|
#include "ZipExport.h"
|
|
#include "ZipExtraData.h"
|
|
#include "ZipCollections.h"
|
|
#include "ZipStorage.h"
|
|
|
|
|
|
#define ZIP_EXTRA_ZARCH_NAME 0x5A4C // ZL - ZipArchive Library
|
|
|
|
#define ZIP_EXTRA_ZARCH_SEEK 0x5A4D
|
|
|
|
|
|
#if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
|
|
#pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
|
|
#endif
|
|
|
|
/**
|
|
Represents a local or central extra field in a zip archive.
|
|
This is a collection of extra data records (CZipExtraData).
|
|
|
|
\see
|
|
<a href="kb">0610242300</a>
|
|
\see
|
|
CZipExtraData
|
|
*/
|
|
class ZIP_API CZipExtraField
|
|
{
|
|
friend class CZipFileHeader;
|
|
public:
|
|
CZipExtraField(){}
|
|
CZipExtraField(const CZipExtraField& arr)
|
|
{
|
|
*this = arr;
|
|
}
|
|
CZipExtraField& operator=(const CZipExtraField& field)
|
|
{
|
|
Clear();
|
|
for (int i = 0; i < field.GetCount(); i++)
|
|
Add(new CZipExtraData(*field.GetAt(i)));
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
Gets the total size, the extra data will occupy in the archive.
|
|
|
|
\return
|
|
The size in bytes.
|
|
*/
|
|
int GetTotalSize() const;
|
|
|
|
/**
|
|
Validates the current size of the extra field.
|
|
|
|
\return
|
|
\c false, if the size is larger than allowed; \c false otherwise.
|
|
*/
|
|
bool Validate() const
|
|
{
|
|
return GetTotalSize() <= USHRT_MAX;
|
|
}
|
|
|
|
/**
|
|
Gets the number of extra data records included in the extra field.
|
|
|
|
\return
|
|
The number of extra fields included.
|
|
*/
|
|
int GetCount() const
|
|
{
|
|
return (int)m_aData.GetSize();
|
|
}
|
|
|
|
/**
|
|
Gets the extra data record at the given index.
|
|
|
|
\param index
|
|
The index of extra data record to retrieve.
|
|
|
|
\return
|
|
The extra data record.
|
|
*/
|
|
CZipExtraData* GetAt(int index) const
|
|
{
|
|
return m_aData.GetAt(index);
|
|
}
|
|
|
|
/**
|
|
Removes the extra data record at the given index.
|
|
|
|
\param index
|
|
The index of the extra data record to remove.
|
|
*/
|
|
void RemoveAt(int index)
|
|
{
|
|
delete (GetAt(index));
|
|
m_aData.RemoveAt(index);
|
|
}
|
|
|
|
/**
|
|
Adds a new extra data record to the extra field.
|
|
|
|
\param pExtra
|
|
The extra data record to add.
|
|
|
|
\return
|
|
The index of \a pExtra in the internal collection.
|
|
*/
|
|
int Add(CZipExtraData* pExtra)
|
|
{
|
|
return (int)m_aData.Add(pExtra);
|
|
}
|
|
|
|
/**
|
|
Creates a new extra data record with the given ID
|
|
and adds it to the extra field.
|
|
|
|
\param headerID
|
|
The extra data ID.
|
|
|
|
\return
|
|
The created extra data record.
|
|
|
|
\see
|
|
CZipExtraData::GetHeaderID
|
|
*/
|
|
CZipExtraData* CreateNew(WORD headerID)
|
|
{
|
|
int temp;
|
|
return CreateNew(headerID, temp);
|
|
}
|
|
|
|
/**
|
|
Creates a new extra data record with the given ID
|
|
and adds it to the extra field.
|
|
|
|
\param headerID
|
|
The extra data ID.
|
|
|
|
\param idx
|
|
Receives the value of the index of the new
|
|
extra data in the internal collection.
|
|
|
|
\return
|
|
The created extra data record.
|
|
|
|
\see
|
|
CZipExtraData::GetHeaderID
|
|
*/
|
|
CZipExtraData* CreateNew(WORD headerID, int& idx)
|
|
{
|
|
CZipExtraData* pData = new CZipExtraData(headerID);
|
|
idx = (int)m_aData.Add(pData);
|
|
return pData;
|
|
}
|
|
|
|
/**
|
|
Removes all extra data records from the 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.
|
|
|
|
\param headerID
|
|
The ID of the extra data to lookup.
|
|
|
|
\return
|
|
The found extra data record or \c NULL, if the extra data could not be found.
|
|
*/
|
|
CZipExtraData* Lookup(WORD headerID) const
|
|
{
|
|
int temp;
|
|
return Lookup(headerID, temp);
|
|
}
|
|
|
|
/**
|
|
Returns the value indicating whether the extra data record with the given ID is present in the extra field.
|
|
|
|
\param headerID
|
|
The ID of the extra data to check.
|
|
|
|
\return
|
|
\c true, if the extra data record with the given ID is present in the extra field; \c false otherwise.
|
|
*/
|
|
bool HasHeader(WORD headerID)
|
|
{
|
|
return Lookup(headerID) != NULL;
|
|
}
|
|
|
|
/**
|
|
Lookups the extra field for the extra data record with the given ID.
|
|
|
|
\param headerID
|
|
The ID of the extra data to lookup.
|
|
|
|
\param index
|
|
Receives the value of the index of the found
|
|
extra data in the internal collection.
|
|
|
|
\return
|
|
The found extra data record or \c NULL, if the extra data could not be found.
|
|
*/
|
|
CZipExtraData* Lookup(WORD headerID, int& index) const;
|
|
~CZipExtraField()
|
|
{
|
|
Clear();
|
|
}
|
|
protected:
|
|
|
|
/**
|
|
Removes all extra data records from the extra field.
|
|
*/
|
|
void Clear()
|
|
{
|
|
for (int i = 0; i < GetCount(); i++)
|
|
delete (GetAt(i));
|
|
m_aData.RemoveAll();
|
|
}
|
|
|
|
/**
|
|
Reads the extra field from \a buffer.
|
|
|
|
\param pStorage
|
|
The storage to read the data from.
|
|
|
|
\param uSize
|
|
The size of the data to read.
|
|
|
|
\return
|
|
\c false, if \a uSize was smaller than the declared extra field size; \c true otherwise.
|
|
*/
|
|
bool Read(CZipStorage* pStorage, WORD uSize);
|
|
|
|
/**
|
|
Writes the extra field to \a buffer.
|
|
|
|
\param buffer
|
|
The buffer to write to.
|
|
*/
|
|
void Write(char* buffer) const;
|
|
private:
|
|
CZipArray<CZipExtraData*> m_aData;
|
|
};
|
|
|
|
|
|
#endif // !defined(ZIPARCHIVE_ZIPEXTRAFIELD_DOT_H)
|