mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 12:07:03 -06:00
4.59 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
3901bf0ab8
commit
173c07e166
Binary file not shown.
|
Before Width: | Height: | Size: 3.6 KiB |
@@ -26,19 +26,19 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
STATPROPSTG kProps[] =
|
||||
STATPROPSTG kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsFolder, VT_BOOL},
|
||||
{ NULL, kpidIsDir, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackedSize, VT_UI8},
|
||||
{ NULL, kpidLastWriteTime, VT_FILETIME}
|
||||
{ NULL, kpidPackSize, VT_UI8},
|
||||
{ NULL, kpidMTime, VT_FILETIME}
|
||||
};
|
||||
|
||||
IMP_IInArchive_Props
|
||||
IMP_IInArchive_ArcProps_NO
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
const UInt64 * /* maxCheckStartPosition */,
|
||||
IArchiveOpenCallback * /* openArchiveCallback */)
|
||||
{
|
||||
@@ -89,15 +89,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
prop = (const wchar_t *)s;
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
case kpidIsDir:
|
||||
prop = false;
|
||||
break;
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
{
|
||||
case kpidPackSize:
|
||||
prop = (UInt64)_archive.GetBootItemSize(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -125,15 +123,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
prop = (const wchar_t *)NItemName::GetOSName2(s);
|
||||
}
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
case kpidIsDir:
|
||||
prop = item.IsDir();
|
||||
break;
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
case kpidPackSize:
|
||||
if (!item.IsDir())
|
||||
prop = (UInt64)item.DataLength;
|
||||
break;
|
||||
case kpidLastWriteTime:
|
||||
case kpidMTime:
|
||||
{
|
||||
FILETIME utcFileTime;
|
||||
if (item.DateTime.GetFileTime(utcFileTime))
|
||||
@@ -242,7 +240,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
streamSpec->Init(currentItemSize);
|
||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
|
||||
RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
|
||||
NArchive::NExtract::NOperationResult::kOK:
|
||||
NArchive::NExtract::NOperationResult::kDataError));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
class CHandler:
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace NIso {
|
||||
|
||||
const char *kElToritoSpec = "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0";
|
||||
|
||||
const wchar_t *kMediaTypes[5] =
|
||||
const wchar_t *kMediaTypes[5] =
|
||||
{
|
||||
L"NoEmulation",
|
||||
L"1.2M",
|
||||
|
||||
@@ -174,7 +174,7 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
|
||||
ReadBytes((Byte *)r.FileId, idLen);
|
||||
int padSize = 1 - (idLen & 1);
|
||||
|
||||
// SkeepZeros(1 - (idLen & 1));
|
||||
// SkeepZeros(1 - (idLen & 1));
|
||||
Skeep(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros
|
||||
|
||||
int curPos = 33 + idLen + padSize;
|
||||
@@ -187,7 +187,7 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
|
||||
|
||||
void CInArchive::ReadDirRecord(CDirRecord &r)
|
||||
{
|
||||
Byte len = ReadByte();
|
||||
Byte len = ReadByte();
|
||||
// Some CDs can have incorrect value len = 48 ('0') in VolumeDescriptor.
|
||||
// But maybe we must use real "len" for other records.
|
||||
len = 34;
|
||||
@@ -218,8 +218,8 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
|
||||
ReadBytes(d.CopyrightFileId, sizeof(d.CopyrightFileId));
|
||||
ReadBytes(d.AbstractFileId, sizeof(d.AbstractFileId));
|
||||
ReadBytes(d.BibFileId, sizeof(d.BibFileId));
|
||||
ReadDateTime(d.CreationTime);
|
||||
ReadDateTime(d.ModificationTime);
|
||||
ReadDateTime(d.CTime);
|
||||
ReadDateTime(d.MTime);
|
||||
ReadDateTime(d.ExpirationTime);
|
||||
ReadDateTime(d.EffectiveTime);
|
||||
d.FileStructureVersion = ReadByte(); // = 1
|
||||
@@ -228,13 +228,19 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
|
||||
SkeepZeros(653);
|
||||
}
|
||||
|
||||
static inline bool CheckDescriptorSignature(const Byte *sig)
|
||||
static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
|
||||
|
||||
static const Byte kSig_NSR02[5] = { 'N', 'S', 'R', '0', '2' };
|
||||
static const Byte kSig_NSR03[5] = { 'N', 'S', 'R', '0', '3' };
|
||||
static const Byte kSig_BEA01[5] = { 'B', 'E', 'A', '0', '1' };
|
||||
static const Byte kSig_TEA01[5] = { 'T', 'E', 'A', '0', '1' };
|
||||
|
||||
static inline bool CheckSignature(const Byte *sig, const Byte *data)
|
||||
{
|
||||
return sig[0] == 'C' &&
|
||||
sig[1] == 'D' &&
|
||||
sig[2] == '0' &&
|
||||
sig[3] == '0' &&
|
||||
sig[4] == '1';
|
||||
for (int i = 0; i < 5; i++)
|
||||
if (sig[i] != data[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CInArchive::SeekToBlock(UInt32 blockIndex)
|
||||
@@ -346,17 +352,41 @@ HRESULT CInArchive::Open2()
|
||||
VolDescs.Add(CVolumeDescriptor());
|
||||
for (;;)
|
||||
{
|
||||
Byte sig[6];
|
||||
ReadBytes(sig, 6);
|
||||
if (!CheckDescriptorSignature(sig + 1))
|
||||
Byte sig[7];
|
||||
ReadBytes(sig, 7);
|
||||
Byte ver = sig[6];
|
||||
if (!CheckSignature(kSig_CD001, sig + 1))
|
||||
{
|
||||
return S_FALSE;
|
||||
/*
|
||||
if (sig[0] != 0 || ver != 1)
|
||||
break;
|
||||
if (CheckSignature(kSig_BEA01, sig + 1))
|
||||
{
|
||||
}
|
||||
else if (CheckSignature(kSig_TEA01, sig + 1))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (CheckSignature(kSig_NSR02, sig + 1))
|
||||
{
|
||||
}
|
||||
else
|
||||
break;
|
||||
SkeepZeros(0x800 - 7);
|
||||
continue;
|
||||
*/
|
||||
}
|
||||
// version = 2 for ISO 9660:1999?
|
||||
Byte ver = ReadByte();
|
||||
if (ver > 2)
|
||||
throw S_FALSE;
|
||||
|
||||
if (sig[0] == NVolDescType::kTerminator)
|
||||
{
|
||||
break;
|
||||
// Skeep(0x800 - 7);
|
||||
// continue;
|
||||
}
|
||||
switch(sig[0])
|
||||
{
|
||||
case NVolDescType::kBootRecord:
|
||||
|
||||
@@ -109,7 +109,7 @@ struct CDateTime
|
||||
Byte Second;
|
||||
Byte Hundredths;
|
||||
signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded.
|
||||
bool NotSpecified() const { return Year == 0 && Month == 0 && Day == 0 &&
|
||||
bool NotSpecified() const { return Year == 0 && Month == 0 && Day == 0 &&
|
||||
Hour == 0 && Minute == 0 && Second == 0 && GmtOffset == 0; }
|
||||
};
|
||||
|
||||
@@ -130,7 +130,7 @@ struct CBootInitialEntry
|
||||
{
|
||||
bool Bootable;
|
||||
Byte BootMediaType;
|
||||
UInt16 LoadSegment;
|
||||
UInt16 LoadSegment;
|
||||
/* This is the load segment for the initial boot image. If this
|
||||
value is 0 the system will use the traditional segment of 7C0. If this value
|
||||
is non-zero the system will use the specified segment. This applies to x86
|
||||
@@ -143,10 +143,10 @@ struct CBootInitialEntry
|
||||
UInt32 LoadRBA; // This is the start address of the virtual disk. CD<43>s use
|
||||
// Relative/Logical block addressing.
|
||||
|
||||
UInt64 GetSize() const
|
||||
{
|
||||
UInt64 GetSize() const
|
||||
{
|
||||
// if (BootMediaType == NBootMediaType::k1d44Floppy) (1440 << 10);
|
||||
return SectorCount * 512;
|
||||
return SectorCount * 512;
|
||||
}
|
||||
|
||||
UString GetName() const
|
||||
@@ -173,7 +173,7 @@ struct CBootInitialEntry
|
||||
struct CVolumeDescriptor
|
||||
{
|
||||
Byte VolFlags;
|
||||
Byte SystemId[32]; // a-characters. An identification of a system
|
||||
Byte SystemId[32]; // a-characters. An identification of a system
|
||||
// which can recognize and act upon the content of the Logical
|
||||
// Sectors with logical Sector Numbers 0 to 15 of the volume.
|
||||
Byte VolumeId[32]; // d-characters. An identification of the volume.
|
||||
@@ -195,19 +195,19 @@ struct CVolumeDescriptor
|
||||
Byte CopyrightFileId[37];
|
||||
Byte AbstractFileId[37];
|
||||
Byte BibFileId[37];
|
||||
CDateTime CreationTime;
|
||||
CDateTime ModificationTime;
|
||||
CDateTime CTime;
|
||||
CDateTime MTime;
|
||||
CDateTime ExpirationTime;
|
||||
CDateTime EffectiveTime;
|
||||
Byte FileStructureVersion; // = 1;
|
||||
Byte ApplicationUse[512];
|
||||
|
||||
bool IsJoliet() const
|
||||
bool IsJoliet() const
|
||||
{
|
||||
if ((VolFlags & 1) != 0)
|
||||
return false;
|
||||
Byte b = EscapeSequence[2];
|
||||
return (EscapeSequence[0] == 0x25 && EscapeSequence[1] == 0x2F &&
|
||||
return (EscapeSequence[0] == 0x25 && EscapeSequence[1] == 0x2F &&
|
||||
(b == 0x40 || b == 0x43 || b == 0x45));
|
||||
}
|
||||
};
|
||||
@@ -272,8 +272,8 @@ public:
|
||||
|
||||
bool IsJoliet() const { return VolDescs[MainVolDescIndex].IsJoliet(); }
|
||||
|
||||
UInt64 GetBootItemSize(int index) const
|
||||
{
|
||||
UInt64 GetBootItemSize(int index) const
|
||||
{
|
||||
const CBootInitialEntry &be = BootEntries[index];
|
||||
UInt64 size = be.GetSize();
|
||||
if (be.BootMediaType == NBootMediaType::k1d2Floppy)
|
||||
@@ -288,7 +288,7 @@ public:
|
||||
if (_archiveSize - startPos < size)
|
||||
size = _archiveSize - startPos;
|
||||
}
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
bool IsSusp;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/Buffer.h"
|
||||
|
||||
#include "Windows/Time.h"
|
||||
|
||||
#include "IsoHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
@@ -24,22 +26,16 @@ struct CRecordingDateTime
|
||||
|
||||
bool GetFileTime(FILETIME &ft) const
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
st.wYear = (WORD)(Year + 1900);
|
||||
st.wMonth = Month;
|
||||
st.wDayOfWeek = 0; // check it
|
||||
st.wDay = Day;
|
||||
st.wHour = Hour;
|
||||
st.wMinute = Minute;
|
||||
st.wSecond = Second;
|
||||
st.wMilliseconds = 0;
|
||||
if (!SystemTimeToFileTime(&st, &ft))
|
||||
return false;
|
||||
UInt64 value = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||
value -= (UInt64)((Int64)GmtOffset * 15 * 60 * 10000000);
|
||||
UInt64 value;
|
||||
bool res = NWindows::NTime::GetSecondsSince1601(Year + 1900, Month, Day, Hour, Minute, Second, value);
|
||||
if (res)
|
||||
{
|
||||
value -= (UInt64)((Int64)GmtOffset * 15 * 60);
|
||||
value *= 10000000;
|
||||
}
|
||||
ft.dwLowDateTime = (DWORD)value;
|
||||
ft.dwHighDateTime = (DWORD)(value >> 32);
|
||||
return true;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,8 +53,8 @@ struct CDirRecord
|
||||
CByteBuffer SystemUse;
|
||||
|
||||
bool IsDir() const { return (FileFlags & NFileFlags::kDirectory) != 0; }
|
||||
bool IsSystemItem() const
|
||||
{
|
||||
bool IsSystemItem() const
|
||||
{
|
||||
if (FileId.GetCapacity() != 1)
|
||||
return false;
|
||||
Byte b = *(const Byte *)FileId;
|
||||
@@ -111,11 +107,11 @@ struct CDirRecord
|
||||
|
||||
bool CheckSusp(const Byte *p, int &startPos) const
|
||||
{
|
||||
if (p[0] == 'S' &&
|
||||
p[1] == 'P' &&
|
||||
p[2] == 0x7 &&
|
||||
p[3] == 0x1 &&
|
||||
p[4] == 0xBE &&
|
||||
if (p[0] == 'S' &&
|
||||
p[1] == 'P' &&
|
||||
p[2] == 0x7 &&
|
||||
p[3] == 0x1 &&
|
||||
p[4] == 0xBE &&
|
||||
p[5] == 0xEF)
|
||||
{
|
||||
startPos = p[6];
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
Reference in New Issue
Block a user