Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RarItem.h « Rar « Archive « 7zip « CPP - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 56d25f2cd8ecd10566fb037dafe308ee274d9542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// RarItem.h

#ifndef __ARCHIVE_RAR_ITEM_H
#define __ARCHIVE_RAR_ITEM_H

#include "../../../Common/StringConvert.h"

#include "RarHeader.h"

namespace NArchive {
namespace NRar {

struct CRarTime
{
  UInt32 DosTime;
  Byte LowSecond;
  Byte SubTime[3];
};

struct CItem
{
  UInt64 Size;
  UInt64 PackSize;
  
  CRarTime CTime;
  CRarTime ATime;
  CRarTime MTime;

  UInt32 FileCRC;
  UInt32 Attrib;

  UInt16 Flags;
  Byte HostOS;
  Byte UnPackVersion;
  Byte Method;

  bool CTimeDefined;
  bool ATimeDefined;

  AString Name;
  UString UnicodeName;

  Byte Salt[8];
  
  bool IsEncrypted()   const { return (Flags & NHeader::NFile::kEncrypted) != 0; }
  bool IsSolid()       const { return (Flags & NHeader::NFile::kSolid) != 0; }
  bool IsCommented()   const { return (Flags & NHeader::NFile::kComment) != 0; }
  bool IsSplitBefore() const { return (Flags & NHeader::NFile::kSplitBefore) != 0; }
  bool IsSplitAfter()  const { return (Flags & NHeader::NFile::kSplitAfter) != 0; }
  bool HasSalt()       const { return (Flags & NHeader::NFile::kSalt) != 0; }
  bool HasExtTime()    const { return (Flags & NHeader::NFile::kExtTime) != 0; }
  bool HasUnicodeName()const { return (Flags & NHeader::NFile::kUnicodeName) != 0; }
  bool IsOldVersion()  const { return (Flags & NHeader::NFile::kOldVersion) != 0; }
  
  UInt32 GetDictSize() const { return (Flags >> NHeader::NFile::kDictBitStart) & NHeader::NFile::kDictMask; }
  bool IsDir() const;
  bool IgnoreItem() const;
  UInt32 GetWinAttrib() const;

  UInt64 Position;
  unsigned MainPartSize;
  UInt16 CommentSize;
  UInt16 AlignSize;

  // int BaseFileIndex;
  // bool IsAltStream;

  UString GetName() const
  {
    if (( /* IsAltStream || */ HasUnicodeName()) && !UnicodeName.IsEmpty())
      return UnicodeName;
    return MultiByteToUnicodeString(Name, CP_OEMCP);
  }

  void Clear()
  {
    CTimeDefined = false;
    ATimeDefined = false;
    Name.Empty();
    UnicodeName.Empty();
    // IsAltStream = false;
    // BaseFileIndex = -1;
  }

  CItem() { Clear(); }

  UInt64 GetFullSize()  const { return MainPartSize + CommentSize + AlignSize + PackSize; };
  //  DWORD GetHeaderWithCommentSize()  const { return MainPartSize + CommentSize; };
  UInt64 GetCommentPosition() const { return Position + MainPartSize; };
  UInt64 GetDataPosition()    const { return GetCommentPosition() + CommentSize + AlignSize; };
};

}}

#endif