mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 03:15:00 -06:00
Update to 7-Zip 17.00 Beta
This commit is contained in:
@@ -38,20 +38,13 @@ struct CHeaderErrorException {};
|
||||
// define CHM_LOW, if you want to see low level items
|
||||
// #define CHM_LOW
|
||||
|
||||
static const GUID kChmLzxGuid = { 0x7FC28940, 0x9D31, 0x11D0, { 0x9B, 0x27, 0x00, 0xA0, 0xC9, 0x1E, 0x9C, 0x7C } };
|
||||
static const GUID kHelp2LzxGuid = { 0x0A9007C6, 0x4076, 0x11D3, { 0x87, 0x89, 0x00, 0x00, 0xF8, 0x10, 0x57, 0x54 } };
|
||||
static const GUID kDesGuid = { 0x67F6E4A2, 0x60BF, 0x11D3, { 0x85, 0x40, 0x00, 0xC0, 0x4F, 0x58, 0xC3, 0xCF } };
|
||||
static const Byte kChmLzxGuid[16] = { 0x40, 0x89, 0xC2, 0x7F, 0x31, 0x9D, 0xD0, 0x11, 0x9B, 0x27, 0x00, 0xA0, 0xC9, 0x1E, 0x9C, 0x7C };
|
||||
static const Byte kHelp2LzxGuid[16] = { 0xC6, 0x07, 0x90, 0x0A, 0x76, 0x40, 0xD3, 0x11, 0x87, 0x89, 0x00, 0x00, 0xF8, 0x10, 0x57, 0x54 };
|
||||
static const Byte kDesGuid[16] = { 0xA2, 0xE4, 0xF6, 0x67, 0xBF, 0x60, 0xD3, 0x11, 0x85, 0x40, 0x00, 0xC0, 0x4F, 0x58, 0xC3, 0xCF };
|
||||
|
||||
static bool AreGuidsEqual(REFGUID g1, REFGUID g2)
|
||||
static bool inline AreGuidsEqual(const Byte *g1, const Byte *g2)
|
||||
{
|
||||
if (g1.Data1 != g2.Data1 ||
|
||||
g1.Data2 != g2.Data2 ||
|
||||
g1.Data3 != g2.Data3)
|
||||
return false;
|
||||
for (int i = 0; i < 8; i++)
|
||||
if (g1.Data4[i] != g2.Data4[i])
|
||||
return false;
|
||||
return true;
|
||||
return memcmp(g1, g2, 16) == 0;
|
||||
}
|
||||
|
||||
static char GetHex(unsigned v)
|
||||
@@ -65,35 +58,12 @@ static void PrintByte(Byte b, AString &s)
|
||||
s += GetHex(b & 0xF);
|
||||
}
|
||||
|
||||
static void PrintUInt16(UInt16 v, AString &s)
|
||||
{
|
||||
PrintByte((Byte)(v >> 8), s);
|
||||
PrintByte((Byte)v, s);
|
||||
}
|
||||
|
||||
static void PrintUInt32(UInt32 v, AString &s)
|
||||
{
|
||||
PrintUInt16((UInt16)(v >> 16), s);
|
||||
PrintUInt16((UInt16)v, s);
|
||||
}
|
||||
|
||||
AString CMethodInfo::GetGuidString() const
|
||||
{
|
||||
AString s;
|
||||
s += '{';
|
||||
PrintUInt32(Guid.Data1, s);
|
||||
s += '-';
|
||||
PrintUInt16(Guid.Data2, s);
|
||||
s += '-';
|
||||
PrintUInt16(Guid.Data3, s);
|
||||
s += '-';
|
||||
PrintByte(Guid.Data4[0], s);
|
||||
PrintByte(Guid.Data4[1], s);
|
||||
s += '-';
|
||||
for (int i = 2; i < 8; i++)
|
||||
PrintByte(Guid.Data4[i], s);
|
||||
s += '}';
|
||||
return s;
|
||||
char s[48];
|
||||
RawLeGuidToString_Braced(Guid, s);
|
||||
// MyStringUpper_Ascii(s);
|
||||
return (AString)s;
|
||||
}
|
||||
|
||||
bool CMethodInfo::IsLzx() const
|
||||
@@ -108,32 +78,28 @@ bool CMethodInfo::IsDes() const
|
||||
return AreGuidsEqual(Guid, kDesGuid);
|
||||
}
|
||||
|
||||
UString CMethodInfo::GetName() const
|
||||
AString CMethodInfo::GetName() const
|
||||
{
|
||||
UString s;
|
||||
AString s;
|
||||
if (IsLzx())
|
||||
{
|
||||
s.SetFromAscii("LZX:");
|
||||
char temp[16];
|
||||
ConvertUInt32ToString(LzxInfo.GetNumDictBits(), temp);
|
||||
s.AddAscii(temp);
|
||||
s = "LZX:";
|
||||
s.Add_UInt32(LzxInfo.GetNumDictBits());
|
||||
}
|
||||
else
|
||||
{
|
||||
AString s2;
|
||||
if (IsDes())
|
||||
s2 = "DES";
|
||||
s = "DES";
|
||||
else
|
||||
{
|
||||
s2 = GetGuidString();
|
||||
s = GetGuidString();
|
||||
if (ControlData.Size() > 0)
|
||||
{
|
||||
s2 += ':';
|
||||
s += ':';
|
||||
for (size_t i = 0; i < ControlData.Size(); i++)
|
||||
PrintByte(ControlData[i], s2);
|
||||
PrintByte(ControlData[i], s);
|
||||
}
|
||||
}
|
||||
ConvertUTF8ToUnicode(s2, s);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -153,7 +119,7 @@ UString CSectionInfo::GetMethodName() const
|
||||
UString temp;
|
||||
if (ConvertUTF8ToUnicode(Name, temp))
|
||||
s += temp;
|
||||
s.AddAscii(": ");
|
||||
s += ": ";
|
||||
}
|
||||
FOR_VECTOR (i, Methods)
|
||||
{
|
||||
@@ -220,12 +186,9 @@ UInt64 CInArchive::ReadEncInt()
|
||||
throw CHeaderErrorException();
|
||||
}
|
||||
|
||||
void CInArchive::ReadGUID(GUID &g)
|
||||
void CInArchive::ReadGUID(Byte *g)
|
||||
{
|
||||
g.Data1 = ReadUInt32();
|
||||
g.Data2 = ReadUInt16();
|
||||
g.Data3 = ReadUInt16();
|
||||
ReadBytes(g.Data4, 8);
|
||||
ReadBytes(g, 16);
|
||||
}
|
||||
|
||||
void CInArchive::ReadString(unsigned size, AString &s)
|
||||
@@ -299,7 +262,7 @@ HRESULT CInArchive::OpenChm(IInStream *inStream, CDatabase &database)
|
||||
// The third and fourth bytes may contain even more fractional bits.
|
||||
// The 4 least significant bits in the last byte are constant.
|
||||
/* UInt32 lang = */ ReadUInt32();
|
||||
GUID g;
|
||||
Byte g[16];
|
||||
ReadGUID(g); // {7C01FD10-7BAA-11D0-9E0C-00A0-C922-E6EC}
|
||||
ReadGUID(g); // {7C01FD11-7BAA-11D0-9E0C-00A0-C922-E6EC}
|
||||
const unsigned kNumSections = 2;
|
||||
@@ -422,7 +385,7 @@ HRESULT CInArchive::OpenHelp2(IInStream *inStream, CDatabase &database)
|
||||
IsArc = true;
|
||||
|
||||
ReadUInt32(); // Len of post-header table
|
||||
GUID g;
|
||||
Byte g[16];
|
||||
ReadGUID(g); // {0A9007C1-4076-11D3-8789-0000F8105754}
|
||||
|
||||
// header section table
|
||||
@@ -637,18 +600,18 @@ HRESULT CInArchive::DecompressStream(IInStream *inStream, const CDatabase &datab
|
||||
|
||||
|
||||
#define DATA_SPACE "::DataSpace/"
|
||||
static const char *kNameList = DATA_SPACE "NameList";
|
||||
static const char *kStorage = DATA_SPACE "Storage/";
|
||||
static const char *kContent = "Content";
|
||||
static const char *kControlData = "ControlData";
|
||||
static const char *kSpanInfo = "SpanInfo";
|
||||
static const char *kTransform = "Transform/";
|
||||
static const char *kResetTable = "/InstanceData/ResetTable";
|
||||
static const char *kTransformList = "List";
|
||||
#define kNameList DATA_SPACE "NameList"
|
||||
#define kStorage DATA_SPACE "Storage/"
|
||||
#define kContent "Content"
|
||||
#define kControlData "ControlData"
|
||||
#define kSpanInfo "SpanInfo"
|
||||
#define kTransform "Transform/"
|
||||
#define kResetTable "/InstanceData/ResetTable"
|
||||
#define kTransformList "List"
|
||||
|
||||
static AString GetSectionPrefix(const AString &name)
|
||||
{
|
||||
AString s = kStorage;
|
||||
AString s (kStorage);
|
||||
s += name;
|
||||
s += '/';
|
||||
return s;
|
||||
@@ -743,7 +706,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
{
|
||||
{
|
||||
// The NameList file
|
||||
RINOK(DecompressStream(inStream, database, kNameList));
|
||||
RINOK(DecompressStream(inStream, database, (AString)kNameList));
|
||||
/* UInt16 length = */ ReadUInt16();
|
||||
UInt16 numSections = ReadUInt16();
|
||||
for (unsigned i = 0; i < numSections; i++)
|
||||
@@ -764,7 +727,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
for (si = 1; si < database.Sections.Size(); si++)
|
||||
{
|
||||
CSectionInfo §ion = database.Sections[si];
|
||||
AString sectionPrefix = GetSectionPrefix(section.Name);
|
||||
AString sectionPrefix (GetSectionPrefix(section.Name));
|
||||
{
|
||||
// Content
|
||||
int index = database.FindItem(sectionPrefix + kContent);
|
||||
@@ -774,7 +737,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
section.Offset = item.Offset;
|
||||
section.CompressedSize = item.Size;
|
||||
}
|
||||
AString transformPrefix = sectionPrefix + kTransform;
|
||||
AString transformPrefix (sectionPrefix + kTransform);
|
||||
if (database.Help2Format)
|
||||
{
|
||||
// Transform List
|
||||
@@ -794,7 +757,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
|
||||
else
|
||||
{
|
||||
CMethodInfo method;
|
||||
method.Guid = kChmLzxGuid;
|
||||
memcpy(method.Guid, kChmLzxGuid, 16);
|
||||
section.Methods.Add(method);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user