1 // HfsHandler.h 2 3 #ifndef ZIP7_INC_HFS_HANDLER_H 4 #define ZIP7_INC_HFS_HANDLER_H 5 6 #include "../../Windows/PropVariant.h" 7 8 #include "../Compress/LzfseDecoder.h" 9 #include "../Compress/ZlibDecoder.h" 10 11 namespace NArchive { 12 namespace NHfs { 13 14 static const UInt32 k_decmpfs_HeaderSize = 16; 15 16 struct CCompressHeader 17 { 18 UInt64 UnpackSize; 19 UInt32 Method; 20 Byte DataPos; 21 bool IsCorrect; 22 bool IsSupported; 23 bool IsResource; 24 IsMethod_Compressed_InlineCCompressHeader25 bool IsMethod_Compressed_Inline() const { return DataPos == k_decmpfs_HeaderSize; } IsMethod_Uncompressed_InlineCCompressHeader26 bool IsMethod_Uncompressed_Inline() const { return DataPos == k_decmpfs_HeaderSize + 1; } IsMethod_ResourceCCompressHeader27 bool IsMethod_Resource() const { return IsResource; } 28 29 void Parse(const Byte *p, size_t size); 30 ClearCCompressHeader31 void Clear() 32 { 33 UnpackSize = 0; 34 Method = 0; 35 DataPos = 0; 36 IsCorrect = false; 37 IsSupported = false; 38 IsResource = false; 39 } 40 CCompressHeaderCCompressHeader41 CCompressHeader() { Clear(); } 42 43 void MethodToProp(NWindows::NCOM::CPropVariant &prop) const; 44 }; 45 46 void MethodsMaskToProp(UInt32 methodsMask, NWindows::NCOM::CPropVariant &prop); 47 48 49 class CDecoder 50 { 51 CMyComPtr2_Create<ICompressCoder, NCompress::NZlib::CDecoder> _zlibDecoder; 52 CMyComPtr2_Create<ICompressCoder, NCompress::NLzfse::CDecoder> _lzfseDecoder; 53 54 CByteBuffer _tableBuf; 55 CByteBuffer _buf; 56 57 HRESULT ExtractResourceFork_ZLIB( 58 ISequentialInStream *inStream, ISequentialOutStream *realOutStream, 59 UInt64 forkSize, UInt64 unpackSize, 60 UInt64 progressStart, IArchiveExtractCallback *extractCallback); 61 62 HRESULT ExtractResourceFork_LZFSE( 63 ISequentialInStream *inStream, ISequentialOutStream *realOutStream, 64 UInt64 forkSize, UInt64 unpackSize, 65 UInt64 progressStart, IArchiveExtractCallback *extractCallback); 66 67 HRESULT ExtractResourceFork_ZBM( 68 ISequentialInStream *inStream, ISequentialOutStream *realOutStream, 69 UInt64 forkSize, UInt64 unpackSize, 70 UInt64 progressStart, IArchiveExtractCallback *extractCallback); 71 72 public: 73 74 HRESULT Extract( 75 ISequentialInStream *inStreamFork, ISequentialOutStream *realOutStream, 76 UInt64 forkSize, 77 const CCompressHeader &compressHeader, 78 const CByteBuffer *data, 79 UInt64 progressStart, IArchiveExtractCallback *extractCallback, 80 int &opRes); 81 82 CDecoder(bool IsAdlerOptional); 83 }; 84 85 }} 86 87 #endif 88