aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Archive/Cab/CabItem.h
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Archive/Cab/CabItem.h')
-rw-r--r--CPP/7zip/Archive/Cab/CabItem.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/CPP/7zip/Archive/Cab/CabItem.h b/CPP/7zip/Archive/Cab/CabItem.h
new file mode 100644
index 0000000..9a912d5
--- /dev/null
+++ b/CPP/7zip/Archive/Cab/CabItem.h
@@ -0,0 +1,66 @@
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
10namespace NArchive {
11namespace NCab {
12
13const unsigned kNumMethodsMax = 16;
14
15struct 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
22 Byte GetMethod() const { return (Byte)(MethodMajor & 0xF); }
23};
24
25struct CItem
26{
27 AString Name;
28 UInt32 Offset;
29 UInt32 Size;
30 UInt32 Time;
31 UInt32 FolderIndex;
32 UInt16 Flags;
33 UInt16 Attributes;
34
35 UInt64 GetEndOffset() const { return (UInt64)Offset + Size; }
36 UInt32 GetWinAttrib() const { return (UInt32)Attributes & ~(UInt32)NHeader::kFileNameIsUtf8_Mask; }
37 bool IsNameUTF() const { return (Attributes & NHeader::kFileNameIsUtf8_Mask) != 0; }
38 bool IsDir() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
39
40 bool ContinuedFromPrev() const
41 {
42 return
43 FolderIndex == NHeader::NFolderIndex::kContinuedFromPrev ||
44 FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext;
45 }
46
47 bool ContinuedToNext() const
48 {
49 return
50 FolderIndex == NHeader::NFolderIndex::kContinuedToNext ||
51 FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext;
52 }
53
54 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