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);
112 CZipString GetSplitVolumeName(ZIP_VOLUME_TYPE uVolume,
bool bLast)
114 if (m_pSplitNames == NULL)
121 return m_pSplitNames->GetVolumeName(m_szArchiveName, (ZIP_VOLUME_TYPE)(uVolume + 1), flags);
138 void UpdateSegmMode(ZIP_VOLUME_TYPE uLastVolume);
150 ZIP_SIZE_TYPE AssureFree(ZIP_SIZE_TYPE uNeeded);
166 void Write(
const void *pBuf, DWORD iSize,
bool bAtOnce);
174 ZIP_SIZE_TYPE GetOccupiedSpace()
const
176 return ZIP_SIZE_TYPE(m_pFile->GetLength() + m_uBytesInWriteBuffer);
182 bool IsClosed(
bool bArchive)
const
185 return !m_state.IsSetAny(stateOpened);
188 return !m_pFile || (m_state.IsSetAny(stateAutoClose) && m_pFile->IsClosed());
205 DWORD
Read(
void* pBuf, DWORD iSize,
bool bAtOnce);
217 ZIP_SIZE_TYPE GetPosition()
const
219 ZIP_SIZE_TYPE uPos = (ZIP_SIZE_TYPE)(m_pFile->GetPosition()) + m_uBytesInWriteBuffer;
220 if (m_uCurrentVolume == 0)
221 uPos -= m_uBytesBeforeZip;
222 else if (IsBinarySplit())
224 ZIP_VOLUME_TYPE uVolume = m_uCurrentVolume;
225 ASSERT(m_pCachedSizes->GetSize() > (ZIP_ARRAY_SIZE_TYPE)(uVolume - 1));
229 uPos += (ZIP_SIZE_TYPE)m_pCachedSizes->GetAt((ZIP_ARRAY_SIZE_TYPE)uVolume);
266 void NextVolume(ZIP_SIZE_TYPE uNeeded);
281 void ChangeVolume(ZIP_VOLUME_TYPE uNumber);
288 ChangeVolume((ZIP_VOLUME_TYPE)(m_uCurrentVolume + 1));
294 void ChangeVolumeDec()
296 if (m_uCurrentVolume == 0)
298 ChangeVolume((ZIP_VOLUME_TYPE)(m_uCurrentVolume - 1));
309 return m_state.IsSetAll(stateSplit);
318 bool IsBinarySplit()
const
320 return m_state.IsSetAll(stateBinarySplit);
329 bool IsRegularSplit()
const
331 return m_state.IsSetAll(stateSplit) && !m_state.IsSetAll(stateBinarySplit);
340 bool IsSpanned()
const
342 return m_state.IsSetAll(stateSpan);
348 bool IsReadOnly()
const
350 return m_state.IsSetAny(stateReadOnly) || IsExistingSegmented();
359 bool IsExistingSegmented()
const
361 return m_state.IsSetAll(stateSegmented | stateExisting);
370 bool IsNewSegmented()
const
372 return m_state.IsSetAny(stateSegmented) && !IsExisting();
381 bool IsSegmented()
const
383 return m_state.IsSetAny(stateSegmented);
392 bool IsExisting()
const
394 return m_state.IsSetAny(stateExisting);
409 ZIPTRACE(
"%s(%i) : The archive is already opened.\n");
413 m_pSplitNames = pNames;
414 m_bAutoDeleteSplitNames = bAutoDelete;
428 return m_pSplitNames;
441 return m_pSplitNames;
454 ULONGLONG Seek(ULONGLONG lOff, SeekType iSeekType = seekFromBeginning);
466 void SeekInBinary(ZIP_FILE_SIZE lOff,
bool bSeekToBegin =
false);
474 ZIP_SIZE_TYPE VolumeLeft()
const;
489 CZipString
Close(
bool bWrite,
bool bGetLastVolumeName =
false);
499 static char m_gszExtHeaderSignat[];
514 ZIP_SIZE_TYPE GetLastDataOffset()
516 return (ZIP_SIZE_TYPE)m_pFile->GetLength() - m_uBytesBeforeZip;
532 ZIP_FILE_USIZE LocateSignature(
char* szSignature, ZIP_SIZE_TYPE uMaxDepth);
538 void EmptyWriteBuffer()
540 m_uBytesInWriteBuffer = 0;
558 bool OpenFile(LPCTSTR lpszName, UINT uFlags,
bool bThrow =
true);
566 CZipString RenameLastFileInSplitArchive();
578 void WriteInternalBuffer(
const char *pBuf, DWORD uSize);
586 ZIP_SIZE_TYPE GetFreeVolumeSpace()
const;
605 void CallCallback(ZIP_SIZE_TYPE uNeeded,
int iCode, CZipString szTemp);
610 CZipString ChangeSplitRead();
615 CZipString ChangeSpannedRead();
623 DWORD
GetFreeInBuffer()
const {
return m_pWriteBuffer.GetSize() - m_uBytesInWriteBuffer;}
706 ZIP_FILE_USIZE LocateSignature(
char* szSignature, ZIP_SIZE_TYPE uMaxDepth,
int& leftToFind,
bool& found, ZIP_FILE_USIZE uFileLength);
708 CZipString GetSplitVolumeName(
bool bLast)
710 return GetSplitVolumeName(m_uCurrentVolume, bLast);
713 void ClearSplitNames()
717 if (m_bAutoDeleteSplitNames)
718 delete m_pSplitNames;
719 m_pSplitNames = NULL;
720 m_bAutoDeleteSplitNames =
false;
724 void ClearCachedSizes()
728 delete m_pCachedSizes;
729 m_pCachedSizes = NULL;
733 void EnsureSplitNames()
737 if (m_pSplitNames == NULL)
739 m_bAutoDeleteSplitNames =
true;
740 if (m_state.IsSetAll(stateBinarySplit))
745 m_pSplitNames->Initialize(m_szArchiveName);
749 ZIP_FILE_USIZE GetCachedSize(ZIP_VOLUME_TYPE uVolume)
751 ASSERT(m_pCachedSizes);
752 if (m_pCachedSizes->GetSize() > (ZIP_ARRAY_SIZE_TYPE)uVolume)
753 return m_pCachedSizes->GetAt((ZIP_ARRAY_SIZE_TYPE)uVolume);
763 CZipString m_szArchiveName;
764 CZipFile m_internalfile;
766 CZipArray<ZIP_FILE_USIZE>* m_pCachedSizes;
767 bool m_bAutoDeleteSplitNames;
768 static const ZIP_FILE_USIZE SignatureNotFound;
772 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
773 #pragma warning (pop)
777 #endif // !defined(ZIPARCHIVE_ZIPSTORAGE_DOT_H)