21 #if !defined(ZIPARCHIVE_ZIPSTORAGE_DOT_H)
22 #define ZIPARCHIVE_ZIPSTORAGE_DOT_H
26 #if defined ZIP_HAS_DLL
27 #pragma warning (push)
28 #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
33 #include "ZipAutoBuffer.h"
34 #include "ZipString.h"
35 #include "ZipMemFile.h"
36 #include "ZipExport.h"
41 #include "ZipCollections.h"
57 stateReadOnly = 0x0002,
58 stateAutoClose = 0x0004,
59 stateExisting = 0x0008,
60 stateSegmented = 0x0010,
61 stateSplit = stateSegmented | 0x0020,
62 stateBinarySplit = stateSplit | 0x0040,
63 stateSpan = stateSegmented | 0x0080
83 static const ZIP_FILE_USIZE SignatureNotFound;
93 void Open(CZipAbstractFile& af,
int iMode,
bool bAutoClose);
100 void Open(LPCTSTR lpszPathName,
int iMode, ZIP_SIZE_TYPE uVolumeSize);
115 CZipString GetSplitVolumeName(ZIP_VOLUME_TYPE uVolume,
bool bLast)
117 if (m_pSplitNames == NULL)
125 return m_pSplitNames->GetVolumeName(m_szArchiveName, (ZIP_VOLUME_TYPE)(uVolume + 1), flags);
142 void UpdateSegmMode(ZIP_VOLUME_TYPE uLastVolume);
154 ZIP_SIZE_TYPE AssureFree(ZIP_SIZE_TYPE uNeeded);
170 void Write(
const void *pBuf, DWORD iSize,
bool bAtOnce);
178 ZIP_SIZE_TYPE GetOccupiedSpace()
const
180 return ZIP_SIZE_TYPE(m_pFile->GetLength() + m_uBytesInWriteBuffer);
186 bool IsClosed(
bool bArchive)
const
189 return !m_state.IsSetAny(stateOpened);
192 return !m_pFile || (m_state.IsSetAny(stateAutoClose) && m_pFile->IsClosed());
209 DWORD
Read(
void* pBuf, DWORD iSize,
bool bAtOnce);
221 ZIP_SIZE_TYPE GetPosition()
const
223 ZIP_SIZE_TYPE uPos = (ZIP_SIZE_TYPE)(m_pFile->GetPosition()) + m_uBytesInWriteBuffer;
224 if (m_uCurrentVolume == 0)
225 uPos -= m_uBytesBeforeZip;
226 else if (IsBinarySplit())
228 ZIP_VOLUME_TYPE uVolume = m_uCurrentVolume;
229 ASSERT(m_pCachedSizes->GetSize() > (ZIP_ARRAY_SIZE_TYPE)(uVolume - 1));
233 uPos += (ZIP_SIZE_TYPE)m_pCachedSizes->GetAt((ZIP_ARRAY_SIZE_TYPE)uVolume);
270 void NextVolume(ZIP_SIZE_TYPE uNeeded);
285 void ChangeVolume(ZIP_VOLUME_TYPE uNumber);
292 ChangeVolume((ZIP_VOLUME_TYPE)(m_uCurrentVolume + 1));
298 void ChangeVolumeDec()
300 if (m_uCurrentVolume == 0)
302 ChangeVolume((ZIP_VOLUME_TYPE)(m_uCurrentVolume - 1));
313 return m_state.IsSetAll(stateSplit);
322 bool IsBinarySplit()
const
324 return m_state.IsSetAll(stateBinarySplit);
333 bool IsRegularSplit()
const
335 return m_state.IsSetAll(stateSplit) && !m_state.IsSetAll(stateBinarySplit);
344 bool IsSpanned()
const
346 return m_state.IsSetAll(stateSpan);
352 bool IsReadOnly()
const
354 return m_state.IsSetAny(stateReadOnly) || IsExistingSegmented();
363 bool IsExistingSegmented()
const
365 return m_state.IsSetAll(stateSegmented | stateExisting);
374 bool IsNewSegmented()
const
376 return m_state.IsSetAny(stateSegmented) && !IsExisting();
385 bool IsSegmented()
const
387 return m_state.IsSetAny(stateSegmented);
396 bool IsExisting()
const
398 return m_state.IsSetAny(stateExisting);
413 ZIPTRACE(
"%s(%i) : The archive is already opened.\n");
417 m_pSplitNames = pNames;
418 m_bAutoDeleteSplitNames = bAutoDelete;
432 return m_pSplitNames;
445 return m_pSplitNames;
458 ULONGLONG Seek(ULONGLONG lOff, SeekType iSeekType = seekFromBeginning);
470 void SeekInBinary(ZIP_FILE_SIZE lOff,
bool bSeekToBegin =
false);
478 ZIP_SIZE_TYPE VolumeLeft()
const;
493 CZipString
Close(
bool bWrite,
bool bGetLastVolumeName =
false);
503 static char m_gszExtHeaderSignat[];
523 ZIP_FILE_USIZE LocateSignature(
char* szSignature, ZIP_SIZE_TYPE uMaxDepth);
533 ZIP_SIZE_TYPE GetLastDataOffset()
535 return (ZIP_SIZE_TYPE)m_pFile->GetLength() - m_uBytesBeforeZip;
541 void EmptyWriteBuffer()
543 m_uBytesInWriteBuffer = 0;
561 bool OpenFile(LPCTSTR lpszName, UINT uFlags,
bool bThrow =
true);
569 CZipString RenameLastFileInSplitArchive();
581 void WriteInternalBuffer(
const char *pBuf, DWORD uSize);
589 ZIP_SIZE_TYPE GetFreeVolumeSpace()
const;
608 void CallCallback(ZIP_SIZE_TYPE uNeeded,
int iCode, CZipString szTemp);
613 CZipString ChangeSplitRead();
618 CZipString ChangeSpannedRead();
626 DWORD
GetFreeInBuffer()
const {
return m_pWriteBuffer.GetSize() - m_uBytesInWriteBuffer;}
709 ZIP_FILE_USIZE LocateSignature(
char* szSignature, ZIP_SIZE_TYPE uMaxDepth,
int& leftToFind,
bool& found, ZIP_FILE_USIZE uFileLength);
711 CZipString GetSplitVolumeName(
bool bLast)
713 return GetSplitVolumeName(m_uCurrentVolume, bLast);
716 void ClearSplitNames()
720 if (m_bAutoDeleteSplitNames)
721 delete m_pSplitNames;
722 m_pSplitNames = NULL;
723 m_bAutoDeleteSplitNames =
false;
727 void ClearCachedSizes()
731 delete m_pCachedSizes;
732 m_pCachedSizes = NULL;
736 void EnsureSplitNames()
740 if (m_pSplitNames == NULL)
742 m_bAutoDeleteSplitNames =
true;
743 if (m_state.IsSetAll(stateBinarySplit))
748 m_pSplitNames->Initialize(m_szArchiveName);
752 ZIP_FILE_USIZE GetCachedSize(ZIP_VOLUME_TYPE uVolume)
754 ASSERT(m_pCachedSizes);
755 if (m_pCachedSizes->GetSize() > (ZIP_ARRAY_SIZE_TYPE)uVolume)
756 return m_pCachedSizes->GetAt((ZIP_ARRAY_SIZE_TYPE)uVolume);
766 CZipString m_szArchiveName;
767 CZipFile m_internalfile;
769 CZipArray<ZIP_FILE_USIZE>* m_pCachedSizes;
770 bool m_bAutoDeleteSplitNames;
774 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
775 #pragma warning (pop)
779 #endif // !defined(ZIPARCHIVE_ZIPSTORAGE_DOT_H)