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

TarItem.h « Tar « Archive « 7zip « CPP - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 10b57cd0684fb30a637d255b607ccf1cf2b926fe (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
// Archive/Tar/Item.h

#ifndef __ARCHIVE_TAR_ITEM_H
#define __ARCHIVE_TAR_ITEM_H

#include <time.h>

#include "Common/Types.h"
#include "Common/MyString.h"

#include "../Common/ItemNameUtils.h"
#include "TarHeader.h"

namespace NArchive {
namespace NTar {

class CItem
{
public:
  AString Name;
  UInt32 Mode;
  UInt32 UID;
  UInt32 GID;
  UInt64 Size;
  UInt32 ModificationTime;
  char LinkFlag;
  AString LinkName;
  char Magic[8];
  AString UserName;
  AString GroupName;

  bool DeviceMajorDefined;
  UInt32 DeviceMajor;
  bool DeviceMinorDefined;
  UInt32 DeviceMinor;

  bool IsDirectory() const 
    {  
      if (LinkFlag == NFileHeader::NLinkFlag::kDirectory)
        return true;
      if (LinkFlag == NFileHeader::NLinkFlag::kOldNormal || 
          LinkFlag == NFileHeader::NLinkFlag::kNormal)
      {
        return NItemName::HasTailSlash(Name, CP_OEMCP);
      }
      return false;
    }

  bool IsMagic() const 
  {  
    for (int i = 0; i < 5; i++)
      if (Magic[i] != NFileHeader::NMagic::kUsTar[i])
        return false;
    return true;
  }
};

class CItemEx: public CItem
{
public:
  UInt64 HeaderPosition;
  UInt64 LongLinkSize;
  UInt64 GetDataPosition() const { return HeaderPosition + LongLinkSize + NFileHeader::kRecordSize; };
  UInt64 GetFullSize() const { return LongLinkSize + NFileHeader::kRecordSize + Size; };
};

}}

#endif