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
90 void Open(CZipAbstractFile& af,
int iMode,
bool bAutoClose);
97 void Open(LPCTSTR lpszPathName,
int iMode, ZIP_SIZE_TYPE uVolumeSize);
114 void UpdateSegmMode(ZIP_VOLUME_TYPE uLastVolume);
126 ZIP_SIZE_TYPE AssureFree(ZIP_SIZE_TYPE uNeeded);
142 void Write(
const void *pBuf, DWORD iSize,
bool bAtOnce);
150 ZIP_SIZE_TYPE GetOccupiedSpace()
const
152 return ZIP_SIZE_TYPE(m_pFile->GetLength() + m_uBytesInWriteBuffer);
158 bool IsClosed(
bool bArchive)
const
161 return !m_state.IsSetAny(stateOpened);
164 return !m_pFile || (m_state.IsSetAny(stateAutoClose) && m_pFile->IsClosed());
181 DWORD
Read(
void* pBuf, DWORD iSize,
bool bAtOnce);
193 ZIP_SIZE_TYPE GetPosition()
const
195 ZIP_SIZE_TYPE uPos = (ZIP_SIZE_TYPE)(m_pFile->GetPosition()) + m_uBytesInWriteBuffer;
196 if (m_uCurrentVolume == 0)
197 uPos -= m_uBytesBeforeZip;
198 else if (IsBinarySplit())
200 ZIP_VOLUME_TYPE uVolume = m_uCurrentVolume;
201 ASSERT(m_pCachedSizes->GetSize() > (ZIP_ARRAY_SIZE_TYPE)(uVolume - 1));
205 uPos += (ZIP_SIZE_TYPE)m_pCachedSizes->GetAt((ZIP_ARRAY_SIZE_TYPE)uVolume);
242 void NextVolume(ZIP_SIZE_TYPE uNeeded);
257 void ChangeVolume(ZIP_VOLUME_TYPE uNumber);
264 ChangeVolume((ZIP_VOLUME_TYPE)(m_uCurrentVolume + 1));
270 void ChangeVolumeDec()
272 if (m_uCurrentVolume == 0)
274 ChangeVolume((ZIP_VOLUME_TYPE)(m_uCurrentVolume - 1));
285 return m_state.IsSetAll(stateSplit);
294 bool IsBinarySplit()
const
296 return m_state.IsSetAll(stateBinarySplit);
305 bool IsRegularSplit()
const
307 return m_state.IsSetAll(stateSplit) && !m_state.IsSetAll(stateBinarySplit);
316 bool IsSpanned()
const
318 return m_state.IsSetAll(stateSpan);
324 bool IsReadOnly()
const
326 return m_state.IsSetAny(stateReadOnly) || IsExistingSegmented();
335 bool IsExistingSegmented()
const
337 return m_state.IsSetAll(stateSegmented | stateExisting);
346 bool IsNewSegmented()
const
348 return m_state.IsSetAny(stateSegmented) && !IsExisting();
357 bool IsSegmented()
const
359 return m_state.IsSetAny(stateSegmented);
368 bool IsExisting()
const
370 return m_state.IsSetAny(stateExisting);
385 ZIPTRACE(
"%s(%i) : The archive is already opened.\n");
389 m_pSplitNames = pNames;
390 m_bAutoDeleteSplitNames = bAutoDelete;
404 return m_pSplitNames;
417 return m_pSplitNames;
430 ULONGLONG Seek(ULONGLONG lOff, SeekType iSeekType = seekFromBeginning);
442 void SeekInBinary(ZIP_FILE_SIZE lOff,
bool bSeekToBegin =
false);
450 ZIP_SIZE_TYPE VolumeLeft()
const;
465 CZipString
Close(
bool bWrite,
bool bGetLastVolumeName =
false);
475 static char m_gszExtHeaderSignat[];
490 ZIP_SIZE_TYPE GetLastDataOffset()
492 return (ZIP_SIZE_TYPE)m_pFile->GetLength() - m_uBytesBeforeZip;
508 ZIP_FILE_USIZE LocateSignature(
char* szSignature, ZIP_SIZE_TYPE uMaxDepth);
514 void EmptyWriteBuffer()
516 m_uBytesInWriteBuffer = 0;
534 bool OpenFile(LPCTSTR lpszName, UINT uFlags,
bool bThrow =
true);
542 CZipString RenameLastFileInSplitArchive();
554 void WriteInternalBuffer(
const char *pBuf, DWORD uSize);
562 ZIP_SIZE_TYPE GetFreeVolumeSpace()
const;
581 void CallCallback(ZIP_SIZE_TYPE uNeeded,
int iCode, CZipString szTemp);
586 CZipString ChangeSplitRead();
591 CZipString ChangeSpannedRead();
599 DWORD
GetFreeInBuffer()
const {
return m_pWriteBuffer.GetSize() - m_uBytesInWriteBuffer;}
682 ZIP_FILE_USIZE LocateSignature(
char* szSignature, ZIP_SIZE_TYPE uMaxDepth,
int& leftToFind,
bool& found, ZIP_FILE_USIZE uFileLength);
683 CZipString GetSplitVolumeName(
bool bLast)
685 if (m_pSplitNames == NULL)
692 return m_pSplitNames->GetVolumeName(m_szArchiveName, (ZIP_VOLUME_TYPE)(m_uCurrentVolume + 1), flags);
695 void ClearSplitNames()
699 if (m_bAutoDeleteSplitNames)
700 delete m_pSplitNames;
701 m_pSplitNames = NULL;
702 m_bAutoDeleteSplitNames =
false;
706 void ClearCachedSizes()
710 delete m_pCachedSizes;
711 m_pCachedSizes = NULL;
715 void EnsureSplitNames()
719 if (m_pSplitNames == NULL)
721 m_bAutoDeleteSplitNames =
true;
722 if (m_state.IsSetAll(stateBinarySplit))
727 m_pSplitNames->Initialize(m_szArchiveName);
731 ZIP_FILE_USIZE GetCachedSize(ZIP_VOLUME_TYPE uVolume)
733 ASSERT(m_pCachedSizes);
734 if (m_pCachedSizes->GetSize() > (ZIP_ARRAY_SIZE_TYPE)uVolume)
735 return m_pCachedSizes->GetAt((ZIP_ARRAY_SIZE_TYPE)uVolume);
745 CZipString m_szArchiveName;
746 CZipFile m_internalfile;
748 CZipArray<ZIP_FILE_USIZE>* m_pCachedSizes;
749 bool m_bAutoDeleteSplitNames;
750 static const ZIP_FILE_USIZE SignatureNotFound;
754 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
755 #pragma warning (pop)
759 #endif // !defined(ZIPARCHIVE_ZIPSTORAGE_DOT_H)