1 // Archive/CabItem.h 2 3 #ifndef __ARCHIVE_CAB_ITEM_H 4 #define __ARCHIVE_CAB_ITEM_H 5 6 #include "../../../Common/MyString.h" 7 8 #include "CabHeader.h" 9 10 namespace NArchive { 11 namespace NCab { 12 13 const unsigned kNumMethodsMax = 16; 14 15 struct CFolder 16 { 17 UInt32 DataStart; // offset of the first CFDATA block in this folder 18 UInt16 NumDataBlocks; // number of CFDATA blocks in this folder 19 Byte MethodMajor; 20 Byte MethodMinor; 21 GetMethodCFolder22 Byte GetMethod() const { return (Byte)(MethodMajor & 0xF); } 23 }; 24 25 struct CItem 26 { 27 AString Name; 28 UInt32 Offset; 29 UInt32 Size; 30 UInt32 Time; 31 UInt32 FolderIndex; 32 UInt16 Flags; 33 UInt16 Attributes; 34 GetEndOffsetCItem35 UInt64 GetEndOffset() const { return (UInt64)Offset + Size; } GetWinAttribCItem36 UInt32 GetWinAttrib() const { return (UInt32)Attributes & ~(UInt32)NHeader::kFileNameIsUtf8_Mask; } IsNameUTFCItem37 bool IsNameUTF() const { return (Attributes & NHeader::kFileNameIsUtf8_Mask) != 0; } IsDirCItem38 bool IsDir() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } 39 ContinuedFromPrevCItem40 bool ContinuedFromPrev() const 41 { 42 return 43 FolderIndex == NHeader::NFolderIndex::kContinuedFromPrev || 44 FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext; 45 } 46 ContinuedToNextCItem47 bool ContinuedToNext() const 48 { 49 return 50 FolderIndex == NHeader::NFolderIndex::kContinuedToNext || 51 FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext; 52 } 53 GetFolderIndexCItem54 int GetFolderIndex(unsigned numFolders) const 55 { 56 if (ContinuedFromPrev()) 57 return 0; 58 if (ContinuedToNext()) 59 return (int)numFolders - 1; 60 return (int)FolderIndex; 61 } 62 }; 63 64 }} 65 66 #endif 67