xref: /aosp_15_r20/external/lzma/CPP/7zip/Archive/Rar/RarItem.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // RarItem.h
2 
3 #ifndef ZIP7_INC_ARCHIVE_RAR_ITEM_H
4 #define ZIP7_INC_ARCHIVE_RAR_ITEM_H
5 
6 #include "../../../Common/StringConvert.h"
7 
8 #include "RarHeader.h"
9 
10 namespace NArchive {
11 namespace NRar {
12 
13 struct CRarTime
14 {
15   UInt32 DosTime;
16   Byte LowSecond;
17   Byte SubTime[3];
18 };
19 
20 struct CItem
21 {
22   UInt64 Size;
23   UInt64 PackSize;
24 
25   CRarTime CTime;
26   CRarTime ATime;
27   CRarTime MTime;
28 
29   UInt32 FileCRC;
30   UInt32 Attrib;
31 
32   UInt16 Flags;
33   Byte HostOS;
34   Byte UnPackVersion;
35   Byte Method;
36 
37   bool CTimeDefined;
38   bool ATimeDefined;
39 
40   AString Name;
41   UString UnicodeName;
42 
43   Byte Salt[8];
44 
Is_Size_DefinedCItem45   bool Is_Size_Defined() const { return Size != (UInt64)(Int64)-1; }
46 
IsEncryptedCItem47   bool IsEncrypted()   const { return (Flags & NHeader::NFile::kEncrypted) != 0; }
IsSolidCItem48   bool IsSolid()       const { return (Flags & NHeader::NFile::kSolid) != 0; }
IsCommentedCItem49   bool IsCommented()   const { return (Flags & NHeader::NFile::kComment) != 0; }
IsSplitBeforeCItem50   bool IsSplitBefore() const { return (Flags & NHeader::NFile::kSplitBefore) != 0; }
IsSplitAfterCItem51   bool IsSplitAfter()  const { return (Flags & NHeader::NFile::kSplitAfter) != 0; }
HasSaltCItem52   bool HasSalt()       const { return (Flags & NHeader::NFile::kSalt) != 0; }
HasExtTimeCItem53   bool HasExtTime()    const { return (Flags & NHeader::NFile::kExtTime) != 0; }
HasUnicodeNameCItem54   bool HasUnicodeName()const { return (Flags & NHeader::NFile::kUnicodeName) != 0; }
IsOldVersionCItem55   bool IsOldVersion()  const { return (Flags & NHeader::NFile::kOldVersion) != 0; }
56 
GetDictSizeCItem57   UInt32 GetDictSize() const { return (Flags >> NHeader::NFile::kDictBitStart) & NHeader::NFile::kDictMask; }
58   bool IsDir() const;
59   bool IgnoreItem() const;
60   UInt32 GetWinAttrib() const;
61 
62   UInt64 Position;
63   unsigned MainPartSize;
64   UInt16 CommentSize;
65   UInt16 AlignSize;
66 
67   // int BaseFileIndex;
68   // bool IsAltStream;
69 
GetNameCItem70   UString GetName() const
71   {
72     if (( /* IsAltStream || */ HasUnicodeName()) && !UnicodeName.IsEmpty())
73       return UnicodeName;
74     return MultiByteToUnicodeString(Name, CP_OEMCP);
75   }
76 
ClearCItem77   void Clear()
78   {
79     CTimeDefined = false;
80     ATimeDefined = false;
81     Name.Empty();
82     UnicodeName.Empty();
83     // IsAltStream = false;
84     // BaseFileIndex = -1;
85   }
86 
CItemCItem87   CItem() { Clear(); }
88 
GetFullSizeCItem89   UInt64 GetFullSize()  const { return MainPartSize + CommentSize + AlignSize + PackSize; }
90   //  DWORD GetHeaderWithCommentSize()  const { return MainPartSize + CommentSize; }
GetCommentPositionCItem91   UInt64 GetCommentPosition() const { return Position + MainPartSize; }
GetDataPositionCItem92   UInt64 GetDataPosition()    const { return GetCommentPosition() + CommentSize + AlignSize; }
93 };
94 
95 }}
96 
97 #endif
98