diff src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipIn.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Archive/Zip/ZipIn.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,116 @@
     1.4 +// Archive/ZipIn.h
     1.5 +
     1.6 +#ifndef __ZIP_IN_H
     1.7 +#define __ZIP_IN_H
     1.8 +
     1.9 +#include "../../../Common/MyCom.h"
    1.10 +#include "../../IStream.h"
    1.11 +
    1.12 +#include "ZipHeader.h"
    1.13 +#include "ZipItemEx.h"
    1.14 +
    1.15 +namespace NArchive {
    1.16 +namespace NZip {
    1.17 +  
    1.18 +class CInArchiveException
    1.19 +{
    1.20 +public:
    1.21 +  enum ECauseType
    1.22 +  {
    1.23 +    kUnexpectedEndOfArchive = 0,
    1.24 +    kArchiceHeaderCRCError,
    1.25 +    kFileHeaderCRCError,
    1.26 +    kIncorrectArchive,
    1.27 +    kDataDescroptorsAreNotSupported,
    1.28 +    kMultiVolumeArchiveAreNotSupported,
    1.29 +    kReadStreamError,
    1.30 +    kSeekStreamError
    1.31 +  }
    1.32 +  Cause;
    1.33 +  CInArchiveException(ECauseType cause): Cause(cause) {}
    1.34 +};
    1.35 +
    1.36 +class CInArchiveInfo
    1.37 +{
    1.38 +public:
    1.39 +  UInt64 Base;
    1.40 +  UInt64 StartPosition;
    1.41 +  CByteBuffer Comment;
    1.42 +  CInArchiveInfo(): Base(0), StartPosition(0) {}
    1.43 +  void Clear()
    1.44 +  {
    1.45 +    Base = 0;
    1.46 +    StartPosition = 0;
    1.47 +    Comment.SetCapacity(0);
    1.48 +  }
    1.49 +};
    1.50 +
    1.51 +class CProgressVirt
    1.52 +{
    1.53 +public:
    1.54 +  STDMETHOD(SetTotal)(UInt64 numFiles) PURE;
    1.55 +  STDMETHOD(SetCompleted)(UInt64 numFiles) PURE;
    1.56 +};
    1.57 +
    1.58 +struct CCdInfo
    1.59 +{
    1.60 +  // UInt64 NumEntries;
    1.61 +  UInt64 Size;
    1.62 +  UInt64 Offset;
    1.63 +};
    1.64 +
    1.65 +class CInArchive
    1.66 +{
    1.67 +  CMyComPtr<IInStream> m_Stream;
    1.68 +  UInt32 m_Signature;
    1.69 +  UInt64 m_StreamStartPosition;
    1.70 +  UInt64 m_Position;
    1.71 +  AString m_NameBuffer;
    1.72 +  
    1.73 +  HRESULT Seek(UInt64 offset);
    1.74 +
    1.75 +  HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
    1.76 +  bool ReadUInt32(UInt32 &signature);
    1.77 +  AString ReadFileName(UInt32 nameSize);
    1.78 +  
    1.79 +  HRESULT ReadBytes(void *data, UInt32 size, UInt32 *processedSize);
    1.80 +  bool ReadBytesAndTestSize(void *data, UInt32 size);
    1.81 +  void SafeReadBytes(void *data, UInt32 size);
    1.82 +  void ReadBuffer(CByteBuffer &buffer, UInt32 size);
    1.83 +  Byte ReadByte();
    1.84 +  UInt16 ReadUInt16();
    1.85 +  UInt32 ReadUInt32();
    1.86 +  UInt64 ReadUInt64();
    1.87 +  
    1.88 +  void IncreaseRealPosition(UInt64 addValue);
    1.89 + 
    1.90 +  void ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
    1.91 +      UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber);
    1.92 +  HRESULT ReadLocalItem(CItemEx &item);
    1.93 +  HRESULT ReadLocalItemDescriptor(CItemEx &item);
    1.94 +  HRESULT ReadCdItem(CItemEx &item);
    1.95 +  HRESULT TryEcd64(UInt64 offset, CCdInfo &cdInfo);
    1.96 +  HRESULT FindCd(CCdInfo &cdInfo);
    1.97 +  HRESULT TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress);
    1.98 +  HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress);
    1.99 +  HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset);
   1.100 +public:
   1.101 +  CInArchiveInfo m_ArchiveInfo;
   1.102 +  bool IsZip64;
   1.103 +
   1.104 +  HRESULT ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress);
   1.105 +  HRESULT ReadLocalItemAfterCdItem(CItemEx &item);
   1.106 +  HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);
   1.107 +  HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
   1.108 +  void Close();
   1.109 +  void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
   1.110 +  bool SeekInArchive(UInt64 position);
   1.111 +  ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
   1.112 +  IInStream* CreateStream();
   1.113 +
   1.114 +  bool IsOpen() const { return m_Stream != NULL; }
   1.115 +};
   1.116 +  
   1.117 +}}
   1.118 +  
   1.119 +#endif