Update to 7-Zip 16.03

This commit is contained in:
Tino Reichardt
2016-09-29 20:02:18 +02:00
parent a2f0a60c42
commit 0e6c1206d2
87 changed files with 1201 additions and 386 deletions

View File

@@ -30,7 +30,14 @@ static const Byte kProps[] =
kpidIsDir,
kpidSize,
kpidPackSize,
kpidMTime
kpidMTime,
// kpidCTime,
// kpidATime,
kpidPosixAttrib,
// kpidUser,
// kpidGroup,
// kpidLinks,
kpidSymLink
};
static const Byte kArcProps[] =
@@ -213,17 +220,87 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = s;
}
break;
case kpidSymLink:
if (_archive.IsSusp)
{
UString s;
UInt32 mode;
if (item.GetPx(_archive.SuspSkipSize, k_Px_Mode, mode))
{
if (((mode >> 12) & 0xF) == 10)
{
AString s8;
if (item.GetSymLink(_archive.SuspSkipSize, s8))
{
s = MultiByteToUnicodeString(s8, CP_OEMCP);
prop = s;
}
}
}
}
break;
case kpidPosixAttrib:
/*
case kpidLinks:
case kpidUser:
case kpidGroup:
*/
{
if (_archive.IsSusp)
{
UInt32 t = 0;
switch (propID)
{
case kpidPosixAttrib: t = k_Px_Mode; break;
/*
case kpidLinks: t = k_Px_Links; break;
case kpidUser: t = k_Px_User; break;
case kpidGroup: t = k_Px_Group; break;
*/
}
UInt32 v;
if (item.GetPx(_archive.SuspSkipSize, t, v))
prop = v;
}
break;
}
case kpidIsDir: prop = item.IsDir(); break;
case kpidSize:
case kpidPackSize:
if (!item.IsDir())
prop = (UInt64)ref.TotalSize;
break;
case kpidMTime:
// case kpidCTime:
// case kpidATime:
{
FILETIME utc;
if (item.DateTime.GetFileTime(utc))
if (/* propID == kpidMTime && */ item.DateTime.GetFileTime(utc))
prop = utc;
/*
else
{
UInt32 t = 0;
switch (propID)
{
case kpidMTime: t = k_Tf_MTime; break;
case kpidCTime: t = k_Tf_CTime; break;
case kpidATime: t = k_Tf_ATime; break;
}
CRecordingDateTime dt;
if (item.GetTf(_archive.SuspSkipSize, t, dt))
{
FILETIME utc;
if (dt.GetFileTime(utc))
prop = utc;
}
}
*/
break;
}
}
@@ -321,8 +398,10 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
UInt64 offset = 0;
for (UInt32 e = 0; e < ref.NumExtents; e++)
{
lps->InSize = lps->OutSize = currentTotalSize + offset;
const CDir &item2 = ref.Dir->_subItems[ref.Index + e];
if (item2.Size == 0)
continue;
lps->InSize = lps->OutSize = currentTotalSize + offset;
RINOK(_stream->Seek((UInt64)item2.ExtentLocation * kBlockSize, STREAM_SEEK_SET, NULL));
streamSpec->Init(item2.Size);
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));

View File

@@ -608,7 +608,7 @@ HRESULT CInArchive::Open2()
for (UInt32 j = 0; j < ref.NumExtents; j++)
{
const CDir &item = ref.Dir->_subItems[ref.Index + j];
if (!item.IsDir())
if (!item.IsDir() && item.Size != 0)
UpdatePhySize(item.ExtentLocation, item.Size);
}
}

View File

@@ -3,6 +3,8 @@
#ifndef __ARCHIVE_ISO_ITEM_H
#define __ARCHIVE_ISO_ITEM_H
#include "../../../../C/CpuArch.h"
#include "../../../Common/MyString.h"
#include "../../../Common/MyBuffer.h"
@@ -38,6 +40,32 @@ struct CRecordingDateTime
}
};
enum EPx
{
k_Px_Mode,
k_Px_Links,
k_Px_User,
k_Px_Group,
k_Px_SerialNumber
// k_Px_Num
};
/*
enum ETf
{
k_Tf_CTime,
k_Tf_MTime,
k_Tf_ATime,
k_Tf_Attrib,
k_Tf_Backup,
k_Tf_Expiration,
k_Tf_Effective
// k_Tf_Num
};
*/
struct CDirRecord
{
UInt32 ExtentLocation;
@@ -69,7 +97,8 @@ struct CDirRecord
return (b == 0 || b == 1);
}
const Byte* FindSuspName(unsigned skipSize, unsigned &lenRes) const
const Byte* FindSuspRecord(unsigned skipSize, Byte id0, Byte id1, unsigned &lenRes) const
{
lenRes = 0;
if (SystemUse.Size() < skipSize)
@@ -81,12 +110,12 @@ struct CDirRecord
unsigned len = p[2];
if (len < 3 || len > rem)
return 0;
if (p[0] == 'N' && p[1] == 'M' && p[3] == 1)
if (p[0] == id0 && p[1] == id1 && p[3] == 1)
{
if (len < 5)
if (len < 4)
return 0; // Check it
lenRes = len - 5;
return p + 5;
lenRes = len - 4;
return p + 4;
}
p += len;
rem -= len;
@@ -94,17 +123,23 @@ struct CDirRecord
return 0;
}
const Byte* GetNameCur(bool checkSusp, int skipSize, unsigned &nameLenRes) const
{
const Byte *res = NULL;
unsigned len = 0;
if (checkSusp)
res = FindSuspName(skipSize, len);
if (!res)
res = FindSuspRecord(skipSize, 'N', 'M', len);
if (!res || len < 1)
{
res = (const Byte *)FileId;
len = (unsigned)FileId.Size();
}
else
{
res++;
len--;
}
unsigned i;
for (i = 0; i < len; i++)
if (res[i] == 0)
@@ -114,6 +149,141 @@ struct CDirRecord
}
const bool GetSymLink(int skipSize, AString &link) const
{
link.Empty();
const Byte *p = NULL;
unsigned len = 0;
p = FindSuspRecord(skipSize, 'S', 'L', len);
if (!p || len < 1)
return false;
if (*p != 0)
return false;
p++;
len--;
while (len != 0)
{
if (len < 2)
return false;
unsigned flags = p[0];
unsigned cl = p[1];
p += 2;
len -= 2;
if (cl > len)
return false;
bool needSlash = false;
if (flags & (1 << 1)) link += "./";
else if (flags & (1 << 2)) link += "../";
else if (flags & (1 << 3)) link += '/';
else
needSlash = true;
for (unsigned i = 0; i < cl; i++)
{
char c = p[i];
if (c == 0)
{
break;
// return false;
}
link += c;
}
p += cl;
len -= cl;
if (len == 0)
break;
if (needSlash)
link += '/';
}
return true;
}
static const bool GetLe32Be32(const Byte *p, UInt32 &dest)
{
UInt32 v1 = GetUi32(p);
UInt32 v2 = GetBe32(p + 4);
if (v1 == v2)
{
dest = v1;
return true;
}
return false;
}
const bool GetPx(int skipSize, unsigned pxType, UInt32 &val) const
{
const Byte *p = NULL;
unsigned len = 0;
p = FindSuspRecord(skipSize, 'P', 'X', len);
if (!p)
return false;
// px.Clear();
if (len < ((unsigned)pxType + 1) * 8)
return false;
return GetLe32Be32(p + pxType * 8, val);
}
/*
const bool GetTf(int skipSize, unsigned pxType, CRecordingDateTime &t) const
{
const Byte *p = NULL;
unsigned len = 0;
p = FindSuspRecord(skipSize, 'T', 'F', len);
if (!p)
return false;
if (len < 1)
return false;
Byte flags = *p++;
len--;
unsigned step = 7;
if (flags & 0x80)
{
step = 17;
return false;
}
if ((flags & (1 << pxType)) == 0)
return false;
for (unsigned i = 0; i < pxType; i++)
{
if (len < step)
return false;
if (flags & (1 << i))
{
p += step;
len -= step;
}
}
if (len < step)
return false;
t.Year = p[0];
t.Month = p[1];
t.Day = p[2];
t.Hour = p[3];
t.Minute = p[4];
t.Second = p[5];
t.GmtOffset = (signed char)p[6];
return true;
}
*/
bool CheckSusp(const Byte *p, unsigned &startPos) const
{
if (p[0] == 'S' &&