blob: 86c2764b05f1b3a40412ae429e815ab027d0759b (
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
// Archive/ZipItem.cpp
#include "StdAfx.h"
#include "ZipHeader.h"
#include "ZipItem.h"
#include "../Common/ItemNameUtils.h"
namespace NArchive {
namespace NZip {
bool operator==(const CVersion &v1, const CVersion &v2)
{
return (v1.Version == v2.Version) && (v1.HostOS == v2.HostOS);
}
bool operator!=(const CVersion &v1, const CVersion &v2)
{
return !(v1 == v2);
}
bool CLocalItem::IsEncrypted() const
{ return (Flags & NFileHeader::NFlags::kEncryptedMask) != 0; }
bool CLocalItem::HasDescriptor() const
{ return (Flags & NFileHeader::NFlags::kDescriptorUsedMask) != 0; }
bool CLocalItem::IsImplodeBigDictionary() const
{
if (CompressionMethod != NFileHeader::NCompressionMethod::kImploded)
throw 12312212;
return (Flags & NFileHeader::NFlags::kImplodeDictionarySizeMask) != 0;
}
bool CLocalItem::IsImplodeLiteralsOn() const
{
if (CompressionMethod != NFileHeader::NCompressionMethod::kImploded)
throw 12312213;
return (Flags & NFileHeader::NFlags::kImplodeLiteralsOnMask) != 0;
}
bool CLocalItem::IsDirectory() const
{
return NItemName::HasTailSlash(Name, GetCodePage());
}
bool CItem::IsDirectory() const
{
if (NItemName::HasTailSlash(Name, GetCodePage()))
return true;
if (!FromCentral)
return false;
WORD highAttributes = WORD((ExternalAttributes >> 16 ) & 0xFFFF);
switch(MadeByVersion.HostOS)
{
case NFileHeader::NHostOS::kAMIGA:
switch (highAttributes & NFileHeader::NAmigaAttribute::kIFMT)
{
case NFileHeader::NAmigaAttribute::kIFDIR:
return true;
case NFileHeader::NAmigaAttribute::kIFREG:
return false;
default:
return false; // change it throw kUnknownAttributes;
}
case NFileHeader::NHostOS::kFAT:
case NFileHeader::NHostOS::kNTFS:
case NFileHeader::NHostOS::kHPFS:
case NFileHeader::NHostOS::kVFAT:
return ((ExternalAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
case NFileHeader::NHostOS::kAtari:
case NFileHeader::NHostOS::kMac:
case NFileHeader::NHostOS::kVMS:
case NFileHeader::NHostOS::kVM_CMS:
case NFileHeader::NHostOS::kAcorn:
case NFileHeader::NHostOS::kMVS:
return false; // change it throw kUnknownAttributes;
default:
/*
switch (highAttributes & NFileHeader::NUnixAttribute::kIFMT)
{
case NFileHeader::NUnixAttribute::kIFDIR:
return true;
default:
return false;
}
*/
return false;
}
}
UInt32 CLocalItem::GetWinAttributes() const
{
DWORD winAttributes = 0;
if (IsDirectory())
winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
return winAttributes;
}
UInt32 CItem::GetWinAttributes() const
{
DWORD winAttributes = 0;
switch(MadeByVersion.HostOS)
{
case NFileHeader::NHostOS::kFAT:
case NFileHeader::NHostOS::kNTFS:
if (FromCentral)
winAttributes = ExternalAttributes;
break;
default:
winAttributes = 0; // must be converted from unix value;
}
if (IsDirectory()) // test it;
winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
return winAttributes;
}
void CLocalItem::SetFlagBits(int startBitNumber, int numBits, int value)
{
UInt16 mask = (UInt16)(((1 << numBits) - 1) << startBitNumber);
Flags &= ~mask;
Flags |= value << startBitNumber;
}
void CLocalItem::SetBitMask(int bitMask, bool enable)
{
if(enable)
Flags |= bitMask;
else
Flags &= ~bitMask;
}
void CLocalItem::SetEncrypted(bool encrypted)
{ SetBitMask(NFileHeader::NFlags::kEncryptedMask, encrypted); }
}}
|