OSDN Git Service

add japanese site html
[sevenzip/7-Zip.git] / 7z457 / CPP / 7zip / Archive / Tar / TarItem.h
1 // Archive/Tar/Item.h
2
3 #ifndef __ARCHIVE_TAR_ITEM_H
4 #define __ARCHIVE_TAR_ITEM_H
5
6 #include <time.h>
7
8 #include "Common/Types.h"
9 #include "Common/MyString.h"
10
11 #include "../Common/ItemNameUtils.h"
12 #include "TarHeader.h"
13
14 namespace NArchive {
15 namespace NTar {
16
17 class CItem
18 {
19 public:
20   AString Name;
21   UInt32 Mode;
22   UInt32 UID;
23   UInt32 GID;
24   UInt64 Size;
25   UInt32 ModificationTime;
26   char LinkFlag;
27   AString LinkName;
28   char Magic[8];
29   AString UserName;
30   AString GroupName;
31
32   bool DeviceMajorDefined;
33   UInt32 DeviceMajor;
34   bool DeviceMinorDefined;
35   UInt32 DeviceMinor;
36
37   bool IsDirectory() const 
38     {  
39       if (LinkFlag == NFileHeader::NLinkFlag::kDirectory)
40         return true;
41       if (LinkFlag == NFileHeader::NLinkFlag::kOldNormal || 
42           LinkFlag == NFileHeader::NLinkFlag::kNormal)
43       {
44         return NItemName::HasTailSlash(Name, CP_OEMCP);
45       }
46       return false;
47     }
48
49   bool IsMagic() const 
50   {  
51     for (int i = 0; i < 5; i++)
52       if (Magic[i] != NFileHeader::NMagic::kUsTar[i])
53         return false;
54     return true;
55   }
56 };
57
58 class CItemEx: public CItem
59 {
60 public:
61   UInt64 HeaderPosition;
62   UInt64 LongLinkSize;
63   UInt64 GetDataPosition() const { return HeaderPosition + LongLinkSize + NFileHeader::kRecordSize; };
64   UInt64 GetFullSize() const { return LongLinkSize + NFileHeader::kRecordSize + Size; };
65 };
66
67 }}
68
69 #endif