mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 22:06:59 -06:00
9.34
This commit is contained in:
committed by
Kornel Lesiński
parent
83f8ddcc5b
commit
f08f4dcc3c
194
CPP/7zip/Archive/Iso/IsoHandler.cpp
Executable file → Normal file
194
CPP/7zip/Archive/Iso/IsoHandler.cpp
Executable file → Normal file
@@ -2,12 +2,12 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/ComTry.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Time.h"
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
#include "../../../Windows/TimeUtils.h"
|
||||
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
@@ -24,22 +24,21 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
static const STATPROPSTG kProps[] =
|
||||
static const Byte kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsDir, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackSize, VT_UI8},
|
||||
{ NULL, kpidMTime, VT_FILETIME}
|
||||
kpidPath,
|
||||
kpidIsDir,
|
||||
kpidSize,
|
||||
kpidPackSize,
|
||||
kpidMTime
|
||||
};
|
||||
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
static const Byte kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidComment, VT_BSTR},
|
||||
{ NULL, kpidCTime, VT_FILETIME},
|
||||
{ NULL, kpidMTime, VT_FILETIME}
|
||||
// { NULL, kpidPhySize, VT_UI8},
|
||||
// { NULL, kpidHeadersSize, VT_UI8}
|
||||
kpidComment,
|
||||
kpidCTime,
|
||||
kpidMTime,
|
||||
// kpidHeadersSize
|
||||
};
|
||||
|
||||
IMP_IInArchive_Props
|
||||
@@ -51,13 +50,10 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
Close();
|
||||
// try
|
||||
{
|
||||
if (_archive.Open(stream) != S_OK)
|
||||
return S_FALSE;
|
||||
RINOK(_archive.Open(stream));
|
||||
_stream = stream;
|
||||
}
|
||||
// catch(...) { return S_FALSE; }
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
@@ -75,9 +71,9 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void AddString(AString &s, const char *name, const Byte *p, int size)
|
||||
static void AddString(AString &s, const char *name, const Byte *p, unsigned size)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
for (i = 0; i < size && p[i]; i++);
|
||||
for (; i > 0 && p[i - 1] == ' '; i--);
|
||||
if (i != 0)
|
||||
@@ -94,12 +90,21 @@ static void AddString(AString &s, const char *name, const Byte *p, int size)
|
||||
|
||||
#define ADD_STRING(n, v) AddString(s, n, vol. ## v, sizeof(vol. ## v))
|
||||
|
||||
static void AddErrorMessage(AString &s, const char *message)
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += ". ";
|
||||
s += message;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
NCOM::CPropVariant prop;
|
||||
if (_stream)
|
||||
{
|
||||
const CVolumeDescriptor &vol = _archive.VolDescs[_archive.MainVolDescIndex];
|
||||
switch(propID)
|
||||
switch (propID)
|
||||
{
|
||||
case kpidComment:
|
||||
{
|
||||
@@ -118,9 +123,35 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
}
|
||||
case kpidCTime: { FILETIME utc; if (vol.CTime.GetFileTime(utc)) prop = utc; break; }
|
||||
case kpidMTime: { FILETIME utc; if (vol.MTime.GetFileTime(utc)) prop = utc; break; }
|
||||
// case kpidPhySize: break;
|
||||
// case kpidHeadersSize: break;
|
||||
case kpidError: if (_archive.IncorrectBigEndian) prop = "Incorrect big-endian headers"; break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (propID)
|
||||
{
|
||||
case kpidPhySize: prop = _archive.PhySize; break;
|
||||
case kpidErrorFlags:
|
||||
{
|
||||
UInt32 v = 0;
|
||||
if (!_archive.IsArc) v |= kpv_ErrorFlags_IsNotArc;
|
||||
if (_archive.UnexpectedEnd) v |= kpv_ErrorFlags_UnexpectedEnd;
|
||||
if (_archive.HeadersError) v |= kpv_ErrorFlags_HeadersError;
|
||||
prop = v;
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidError:
|
||||
{
|
||||
AString s;
|
||||
if (_archive.IncorrectBigEndian)
|
||||
AddErrorMessage(s, "Incorrect big-endian headers");
|
||||
if (_archive.SelfLinkedDirs)
|
||||
AddErrorMessage(s, "Self-linked directory");
|
||||
if (_archive.TooDeepDirs)
|
||||
AddErrorMessage(s, "Too deep directory levels");
|
||||
if (!s.IsEmpty())
|
||||
prop = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
@@ -130,22 +161,22 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
NCOM::CPropVariant prop;
|
||||
if (index >= (UInt32)_archive.Refs.Size())
|
||||
{
|
||||
index -= _archive.Refs.Size();
|
||||
const CBootInitialEntry &be = _archive.BootEntries[index];
|
||||
switch(propID)
|
||||
switch (propID)
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
// wchar_t name[32];
|
||||
// ConvertUInt64ToString(index + 1, name);
|
||||
UString s = L"[BOOT]" WSTRING_PATH_SEPARATOR;
|
||||
// char name[16];
|
||||
// ConvertUInt32ToString(index + 1, name);
|
||||
AString s = "[BOOT]" STRING_PATH_SEPARATOR;
|
||||
// s += name;
|
||||
// s += L"-";
|
||||
// s += '-';
|
||||
s += be.GetName();
|
||||
prop = (const wchar_t *)s;
|
||||
prop = s;
|
||||
break;
|
||||
}
|
||||
case kpidIsDir: prop = false; break;
|
||||
@@ -159,7 +190,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
{
|
||||
const CRef &ref = _archive.Refs[index];
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index];
|
||||
switch(propID)
|
||||
switch (propID)
|
||||
{
|
||||
case kpidPath:
|
||||
// if (item.FileId.GetCapacity() >= 0)
|
||||
@@ -171,9 +202,9 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
s = MultiByteToUnicodeString(item.GetPath(_archive.IsSusp, _archive.SuspSkipSize), CP_OEMCP);
|
||||
|
||||
int pos = s.ReverseFind(L';');
|
||||
if (pos >= 0 && pos == s.Length() - 2)
|
||||
if (pos >= 0 && pos == (int)s.Len() - 2)
|
||||
if (s.Back() == L'1')
|
||||
s = s.Left(pos);
|
||||
s.DeleteFrom(pos);
|
||||
if (!s.IsEmpty())
|
||||
if (s.Back() == L'.')
|
||||
s.DeleteBack();
|
||||
@@ -184,7 +215,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
case kpidSize:
|
||||
case kpidPackSize:
|
||||
if (!item.IsDir())
|
||||
prop = (UInt64)item.DataLength;
|
||||
prop = (UInt64)ref.TotalSize;
|
||||
break;
|
||||
case kpidMTime:
|
||||
{
|
||||
@@ -204,7 +235,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 testMode, IArchiveExtractCallback *extractCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool allFilesMode = (numItems == (UInt32)-1);
|
||||
bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
||||
if (allFilesMode)
|
||||
numItems = _archive.Refs.Size();
|
||||
if (numItems == 0)
|
||||
@@ -219,7 +250,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
const CRef &ref = _archive.Refs[index];
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index];
|
||||
if (!item.IsDir())
|
||||
totalSize += item.DataLength;
|
||||
totalSize += ref.TotalSize;
|
||||
}
|
||||
else
|
||||
totalSize += _archive.GetBootItemSize(index - _archive.Refs.Size());
|
||||
@@ -240,9 +271,6 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
CMyComPtr<ISequentialInStream> inStream(streamSpec);
|
||||
streamSpec->SetStream(_stream);
|
||||
|
||||
CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
|
||||
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
|
||||
|
||||
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
|
||||
{
|
||||
lps->InSize = lps->OutSize = currentTotalSize;
|
||||
@@ -267,28 +295,54 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
|
||||
continue;
|
||||
}
|
||||
currentItemSize = item.DataLength;
|
||||
currentItemSize = ref.TotalSize;
|
||||
blockIndex = item.ExtentLocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
int bootIndex = index - _archive.Refs.Size();
|
||||
unsigned bootIndex = index - _archive.Refs.Size();
|
||||
const CBootInitialEntry &be = _archive.BootEntries[bootIndex];
|
||||
currentItemSize = _archive.GetBootItemSize(bootIndex);
|
||||
blockIndex = be.LoadRBA;
|
||||
}
|
||||
|
||||
|
||||
if (!testMode && !realOutStream)
|
||||
continue;
|
||||
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
outStreamSpec->SetStream(realOutStream);
|
||||
|
||||
bool isOK = true;
|
||||
if (index < (UInt32)_archive.Refs.Size())
|
||||
{
|
||||
const CRef &ref = _archive.Refs[index];
|
||||
UInt64 offset = 0;
|
||||
for (UInt32 e = 0; e < ref.NumExtents; e++)
|
||||
{
|
||||
if (e != 0)
|
||||
lps->InSize = lps->OutSize = currentTotalSize + offset;
|
||||
const CDir &item2 = ref.Dir->_subItems[ref.Index + e];
|
||||
RINOK(_stream->Seek(item2.ExtentLocation * _archive.BlockSize, STREAM_SEEK_SET, NULL));
|
||||
streamSpec->Init(item2.Size);
|
||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||
if (copyCoderSpec->TotalSize != item2.Size)
|
||||
{
|
||||
isOK = false;
|
||||
break;
|
||||
}
|
||||
offset += item2.Size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(_stream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL));
|
||||
streamSpec->Init(currentItemSize);
|
||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||
if (copyCoderSpec->TotalSize != currentItemSize)
|
||||
isOK = false;
|
||||
}
|
||||
realOutStream.Release();
|
||||
outStreamSpec->Init(currentItemSize);
|
||||
RINOK(_stream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL));
|
||||
streamSpec->Init(currentItemSize);
|
||||
RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
|
||||
outStreamSpec->ReleaseStream();
|
||||
RINOK(extractCallback->SetOperationResult(outStreamSpec->IsFinishedOK() ?
|
||||
RINOK(extractCallback->SetOperationResult(isOK ?
|
||||
NExtract::NOperationResult::kOK:
|
||||
NExtract::NOperationResult::kDataError));
|
||||
}
|
||||
@@ -308,12 +362,42 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index];
|
||||
if (item.IsDir())
|
||||
return S_FALSE;
|
||||
currentItemSize = item.DataLength;
|
||||
|
||||
if (ref.NumExtents > 1)
|
||||
{
|
||||
CExtentsStream *extentStreamSpec = new CExtentsStream();
|
||||
CMyComPtr<ISequentialInStream> extentStream = extentStreamSpec;
|
||||
|
||||
extentStreamSpec->Stream = _stream;
|
||||
|
||||
UInt64 virtOffset = 0;
|
||||
for (UInt32 i = 0; i < ref.NumExtents; i++)
|
||||
{
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index + i];
|
||||
if (item.Size == 0)
|
||||
continue;
|
||||
CSeekExtent se;
|
||||
se.Phy = (UInt64)item.ExtentLocation * _archive.BlockSize;
|
||||
se.Virt = virtOffset;
|
||||
extentStreamSpec->Extents.Add(se);
|
||||
virtOffset += item.Size;
|
||||
}
|
||||
if (virtOffset != ref.TotalSize)
|
||||
return S_FALSE;
|
||||
CSeekExtent se;
|
||||
se.Phy = 0;
|
||||
se.Virt = virtOffset;
|
||||
extentStreamSpec->Extents.Add(se);
|
||||
extentStreamSpec->Init();
|
||||
*stream = extentStream.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
currentItemSize = item.Size;
|
||||
blockIndex = item.ExtentLocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
int bootIndex = index - _archive.Refs.Size();
|
||||
unsigned bootIndex = index - _archive.Refs.Size();
|
||||
const CBootInitialEntry &be = _archive.BootEntries[bootIndex];
|
||||
currentItemSize = _archive.GetBootItemSize(bootIndex);
|
||||
blockIndex = be.LoadRBA;
|
||||
|
||||
3
CPP/7zip/Archive/Iso/IsoHandler.h
Executable file → Normal file
3
CPP/7zip/Archive/Iso/IsoHandler.h
Executable file → Normal file
@@ -3,7 +3,8 @@
|
||||
#ifndef __ISO_HANDLER_H
|
||||
#define __ISO_HANDLER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
#include "../IArchive.h"
|
||||
|
||||
#include "IsoIn.h"
|
||||
|
||||
12
CPP/7zip/Archive/Iso/IsoHeader.cpp
Executable file → Normal file
12
CPP/7zip/Archive/Iso/IsoHeader.cpp
Executable file → Normal file
@@ -9,13 +9,13 @@ namespace NIso {
|
||||
|
||||
const char *kElToritoSpec = "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0";
|
||||
|
||||
const wchar_t *kMediaTypes[5] =
|
||||
const char *kMediaTypes[5] =
|
||||
{
|
||||
L"NoEmulation",
|
||||
L"1.2M",
|
||||
L"1.44M",
|
||||
L"2.88M",
|
||||
L"HardDisk"
|
||||
"NoEmulation"
|
||||
, "1.2M"
|
||||
, "1.44M"
|
||||
, "2.88M"
|
||||
, "HardDisk"
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
9
CPP/7zip/Archive/Iso/IsoHeader.h
Executable file → Normal file
9
CPP/7zip/Archive/Iso/IsoHeader.h
Executable file → Normal file
@@ -3,7 +3,7 @@
|
||||
#ifndef __ARCHIVE_ISO_HEADER_H
|
||||
#define __ARCHIVE_ISO_HEADER_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
#include "../../../Common/MyTypes.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
@@ -22,6 +22,7 @@ const Byte kVersion = 1;
|
||||
namespace NFileFlags
|
||||
{
|
||||
const Byte kDirectory = 1 << 1;
|
||||
const Byte kNonFinalExtent = 1 << 7;
|
||||
}
|
||||
|
||||
extern const char *kElToritoSpec;
|
||||
@@ -42,7 +43,7 @@ namespace NBootPlatformId
|
||||
const Byte kMac = 2;
|
||||
}
|
||||
|
||||
const BYTE kBootMediaTypeMask = 0xF;
|
||||
const Byte kBootMediaTypeMask = 0xF;
|
||||
|
||||
namespace NBootMediaType
|
||||
{
|
||||
@@ -53,8 +54,8 @@ namespace NBootMediaType
|
||||
const Byte kHardDisk = 4;
|
||||
}
|
||||
|
||||
const int kNumBootMediaTypes = 5;
|
||||
extern const wchar_t *kMediaTypes[];
|
||||
const unsigned kNumBootMediaTypes = 5;
|
||||
extern const char *kMediaTypes[];
|
||||
|
||||
}}
|
||||
|
||||
|
||||
197
CPP/7zip/Archive/Iso/IsoIn.cpp
Executable file → Normal file
197
CPP/7zip/Archive/Iso/IsoIn.cpp
Executable file → Normal file
@@ -2,24 +2,34 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "IsoIn.h"
|
||||
#include "../../../Common/MyException.h"
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "IsoIn.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
struct CUnexpectedEndException {};
|
||||
struct CHeaderErrorException {};
|
||||
struct CEndianErrorException {};
|
||||
|
||||
Byte CInArchive::ReadByte()
|
||||
{
|
||||
if (m_BufferPos >= BlockSize)
|
||||
m_BufferPos = 0;
|
||||
if (m_BufferPos == 0)
|
||||
{
|
||||
size_t processedSize = BlockSize;
|
||||
if (ReadStream(_stream, m_Buffer, &processedSize) != S_OK)
|
||||
throw 1;
|
||||
if (processedSize != BlockSize)
|
||||
throw 1;
|
||||
size_t processed = BlockSize;
|
||||
HRESULT res = ReadStream(_stream, m_Buffer, &processed);
|
||||
if (res != S_OK)
|
||||
throw CSystemException(res);
|
||||
if (processed != BlockSize)
|
||||
throw CUnexpectedEndException();
|
||||
UInt64 end = _position + processed;
|
||||
if (PhySize < end)
|
||||
PhySize = end;
|
||||
}
|
||||
Byte b = m_Buffer[m_BufferPos++];
|
||||
_position++;
|
||||
@@ -44,16 +54,16 @@ void CInArchive::SkipZeros(size_t size)
|
||||
{
|
||||
Byte b = ReadByte();
|
||||
if (b != 0)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
}
|
||||
}
|
||||
|
||||
UInt16 CInArchive::ReadUInt16Spec()
|
||||
{
|
||||
UInt16 value = 0;
|
||||
UInt16 val = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
value |= ((UInt16)(ReadByte()) << (8 * i));
|
||||
return value;
|
||||
val |= ((UInt16)(ReadByte()) << (8 * i));
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,47 +71,47 @@ UInt16 CInArchive::ReadUInt16()
|
||||
{
|
||||
Byte b[4];
|
||||
ReadBytes(b, 4);
|
||||
UInt32 value = 0;
|
||||
UInt32 val = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (b[i] != b[3 - i])
|
||||
IncorrectBigEndian = true;
|
||||
value |= ((UInt16)(b[i]) << (8 * i));
|
||||
val |= ((UInt16)(b[i]) << (8 * i));
|
||||
}
|
||||
return (UInt16)value;
|
||||
return (UInt16)val;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadUInt32Le()
|
||||
{
|
||||
UInt32 value = 0;
|
||||
UInt32 val = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
value |= ((UInt32)(ReadByte()) << (8 * i));
|
||||
return value;
|
||||
val |= ((UInt32)(ReadByte()) << (8 * i));
|
||||
return val;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadUInt32Be()
|
||||
{
|
||||
UInt32 value = 0;
|
||||
UInt32 val = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
value <<= 8;
|
||||
value |= ReadByte();
|
||||
val <<= 8;
|
||||
val |= ReadByte();
|
||||
}
|
||||
return value;
|
||||
return val;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadUInt32()
|
||||
{
|
||||
Byte b[8];
|
||||
ReadBytes(b, 8);
|
||||
UInt32 value = 0;
|
||||
UInt32 val = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (b[i] != b[7 - i])
|
||||
throw 1;
|
||||
value |= ((UInt32)(b[i]) << (8 * i));
|
||||
throw CEndianErrorException();
|
||||
val |= ((UInt32)(b[i]) << (8 * i));
|
||||
}
|
||||
return value;
|
||||
return val;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadDigits(int numDigits)
|
||||
@@ -115,7 +125,7 @@ UInt32 CInArchive::ReadDigits(int numDigits)
|
||||
if (b == 0) // it's bug in some CD's
|
||||
b = '0';
|
||||
else
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
}
|
||||
UInt32 d = (UInt32)(b - '0');
|
||||
res *= 10;
|
||||
@@ -158,16 +168,16 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
|
||||
{
|
||||
r.ExtendedAttributeRecordLen = ReadByte();
|
||||
if (r.ExtendedAttributeRecordLen != 0)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
r.ExtentLocation = ReadUInt32();
|
||||
r.DataLength = ReadUInt32();
|
||||
r.Size = ReadUInt32();
|
||||
ReadRecordingDateTime(r.DateTime);
|
||||
r.FileFlags = ReadByte();
|
||||
r.FileUnitSize = ReadByte();
|
||||
r.InterleaveGapSize = ReadByte();
|
||||
r.VolSequenceNumber = ReadUInt16();
|
||||
Byte idLen = ReadByte();
|
||||
r.FileId.SetCapacity(idLen);
|
||||
r.FileId.Alloc(idLen);
|
||||
ReadBytes((Byte *)r.FileId, idLen);
|
||||
int padSize = 1 - (idLen & 1);
|
||||
|
||||
@@ -176,9 +186,9 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
|
||||
|
||||
int curPos = 33 + idLen + padSize;
|
||||
if (curPos > len)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
int rem = len - curPos;
|
||||
r.SystemUse.SetCapacity(rem);
|
||||
r.SystemUse.Alloc(rem);
|
||||
ReadBytes((Byte *)r.SystemUse, rem);
|
||||
}
|
||||
|
||||
@@ -242,15 +252,34 @@ static inline bool CheckSignature(const Byte *sig, const Byte *data)
|
||||
|
||||
void CInArchive::SeekToBlock(UInt32 blockIndex)
|
||||
{
|
||||
if (_stream->Seek((UInt64)blockIndex * VolDescs[MainVolDescIndex].LogicalBlockSize, STREAM_SEEK_SET, &_position) != S_OK)
|
||||
throw 1;
|
||||
HRESULT res = _stream->Seek((UInt64)blockIndex * VolDescs[MainVolDescIndex].LogicalBlockSize, STREAM_SEEK_SET, &_position);
|
||||
if (res != S_OK)
|
||||
throw CSystemException(res);
|
||||
m_BufferPos = 0;
|
||||
}
|
||||
|
||||
static const int kNumLevelsMax = 256;
|
||||
|
||||
void CInArchive::ReadDir(CDir &d, int level)
|
||||
{
|
||||
if (!d.IsDir())
|
||||
return;
|
||||
if (level > kNumLevelsMax)
|
||||
{
|
||||
TooDeepDirs = true;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
FOR_VECTOR (i, UniqStartLocations)
|
||||
if (UniqStartLocations[i] == d.ExtentLocation)
|
||||
{
|
||||
SelfLinkedDirs = true;
|
||||
return;
|
||||
}
|
||||
UniqStartLocations.Add(d.ExtentLocation);
|
||||
}
|
||||
|
||||
SeekToBlock(d.ExtentLocation);
|
||||
UInt64 startPos = _position;
|
||||
|
||||
@@ -258,7 +287,7 @@ void CInArchive::ReadDir(CDir &d, int level)
|
||||
for (;;)
|
||||
{
|
||||
UInt64 offset = _position - startPos;
|
||||
if (offset >= d.DataLength)
|
||||
if (offset >= d.Size)
|
||||
break;
|
||||
Byte len = ReadByte();
|
||||
if (len == 0)
|
||||
@@ -273,21 +302,44 @@ void CInArchive::ReadDir(CDir &d, int level)
|
||||
|
||||
firstItem = false;
|
||||
}
|
||||
for (int i = 0; i < d._subItems.Size(); i++)
|
||||
FOR_VECTOR (i, d._subItems)
|
||||
ReadDir(d._subItems[i], level + 1);
|
||||
|
||||
UniqStartLocations.DeleteBack();
|
||||
}
|
||||
|
||||
void CInArchive::CreateRefs(CDir &d)
|
||||
{
|
||||
if (!d.IsDir())
|
||||
return;
|
||||
for (int i = 0; i < d._subItems.Size(); i++)
|
||||
for (unsigned i = 0; i < d._subItems.Size();)
|
||||
{
|
||||
CRef ref;
|
||||
CDir &subItem = d._subItems[i];
|
||||
subItem.Parent = &d;
|
||||
ref.Dir = &d;
|
||||
ref.Index = i;
|
||||
ref.Index = i++;
|
||||
ref.NumExtents = 1;
|
||||
ref.TotalSize = subItem.Size;
|
||||
if (subItem.IsNonFinalExtent())
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (i == d._subItems.Size())
|
||||
{
|
||||
HeadersError = true;
|
||||
break;
|
||||
}
|
||||
const CDir &next = d._subItems[i];
|
||||
if (!subItem.AreMultiPartEqualWith(next))
|
||||
break;
|
||||
i++;
|
||||
ref.NumExtents++;
|
||||
ref.TotalSize += next.Size;
|
||||
if (!next.IsNonFinalExtent())
|
||||
break;
|
||||
}
|
||||
}
|
||||
Refs.Add(ref);
|
||||
CreateRefs(subItem);
|
||||
}
|
||||
@@ -310,13 +362,13 @@ void CInArchive::ReadBootInfo()
|
||||
CBootValidationEntry e;
|
||||
e.PlatformId = ReadByte();
|
||||
if (ReadUInt16Spec() != 0)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
ReadBytes(e.Id, sizeof(e.Id));
|
||||
/* UInt16 checkSum = */ ReadUInt16Spec();
|
||||
if (ReadByte() != 0x55)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
if (ReadByte() != 0xAA)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
}
|
||||
b = ReadByte();
|
||||
if (b == NBootEntryId::kInitialEntryBootable || b == NBootEntryId::kInitialEntryNotBootable)
|
||||
@@ -327,11 +379,11 @@ void CInArchive::ReadBootInfo()
|
||||
e.LoadSegment = ReadUInt16Spec();
|
||||
e.SystemType = ReadByte();
|
||||
if (ReadByte() != 0)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
e.SectorCount = ReadUInt16Spec();
|
||||
e.LoadRBA = ReadUInt32Le();
|
||||
if (ReadByte() != 0)
|
||||
throw 1;
|
||||
throw CHeaderErrorException();
|
||||
BootEntries.Add(e);
|
||||
}
|
||||
else
|
||||
@@ -340,16 +392,22 @@ void CInArchive::ReadBootInfo()
|
||||
|
||||
HRESULT CInArchive::Open2()
|
||||
{
|
||||
Clear();
|
||||
RINOK(_stream->Seek(kStartPos, STREAM_SEEK_CUR, &_position));
|
||||
_position = 0;
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_END, &_fileSize));
|
||||
if (_fileSize < kStartPos)
|
||||
return S_FALSE;
|
||||
RINOK(_stream->Seek(kStartPos, STREAM_SEEK_SET, &_position));
|
||||
|
||||
PhySize = _position;
|
||||
m_BufferPos = 0;
|
||||
BlockSize = kBlockSize;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Byte sig[7];
|
||||
ReadBytes(sig, 7);
|
||||
Byte ver = sig[6];
|
||||
|
||||
if (!CheckSignature(kSig_CD001, sig + 1))
|
||||
{
|
||||
return S_FALSE;
|
||||
@@ -372,9 +430,10 @@ HRESULT CInArchive::Open2()
|
||||
continue;
|
||||
*/
|
||||
}
|
||||
|
||||
// version = 2 for ISO 9660:1999?
|
||||
if (ver > 2)
|
||||
throw S_FALSE;
|
||||
return S_FALSE;
|
||||
|
||||
if (sig[0] == NVolDescType::kTerminator)
|
||||
{
|
||||
@@ -382,7 +441,8 @@ HRESULT CInArchive::Open2()
|
||||
// Skip(0x800 - 7);
|
||||
// continue;
|
||||
}
|
||||
switch(sig[0])
|
||||
|
||||
switch (sig[0])
|
||||
{
|
||||
case NVolDescType::kBootRecord:
|
||||
{
|
||||
@@ -408,6 +468,7 @@ HRESULT CInArchive::Open2()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (VolDescs.IsEmpty())
|
||||
return S_FALSE;
|
||||
for (MainVolDescIndex = VolDescs.Size() - 1; MainVolDescIndex > 0; MainVolDescIndex--)
|
||||
@@ -417,30 +478,58 @@ HRESULT CInArchive::Open2()
|
||||
const CVolumeDescriptor &vd = VolDescs[MainVolDescIndex];
|
||||
if (vd.LogicalBlockSize != kBlockSize)
|
||||
return S_FALSE;
|
||||
|
||||
IsArc = true;
|
||||
|
||||
(CDirRecord &)_rootDir = vd.RootDirRecord;
|
||||
ReadDir(_rootDir, 0);
|
||||
CreateRefs(_rootDir);
|
||||
ReadBootInfo();
|
||||
|
||||
{
|
||||
FOR_VECTOR(i, Refs)
|
||||
{
|
||||
const CRef &ref = Refs[i];
|
||||
for (UInt32 j = 0; j < ref.NumExtents; j++)
|
||||
{
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index + j];
|
||||
if (!item.IsDir())
|
||||
UpdatePhySize(item.ExtentLocation, item.Size);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
FOR_VECTOR(i, BootEntries)
|
||||
{
|
||||
const CBootInitialEntry &be = BootEntries[i];
|
||||
UpdatePhySize(be.LoadRBA, GetBootItemSize(i));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::Open(IInStream *inStream)
|
||||
{
|
||||
Clear();
|
||||
_stream = inStream;
|
||||
UInt64 pos;
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &pos));
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_END, &_archiveSize));
|
||||
RINOK(_stream->Seek(pos, STREAM_SEEK_SET, &_position));
|
||||
HRESULT res = S_FALSE;
|
||||
try { res = Open2(); }
|
||||
catch(...) { Clear(); res = S_FALSE; }
|
||||
_stream.Release();
|
||||
return res;
|
||||
try { return Open2(); }
|
||||
catch(const CSystemException &e) { return e.ErrorCode; }
|
||||
catch(CUnexpectedEndException &) { UnexpectedEnd = true; return S_FALSE; }
|
||||
catch(CHeaderErrorException &) { HeadersError = true; return S_FALSE; }
|
||||
catch(CEndianErrorException &) { IncorrectBigEndian = true; return S_FALSE; }
|
||||
}
|
||||
|
||||
void CInArchive::Clear()
|
||||
{
|
||||
IsArc = false;
|
||||
UnexpectedEnd = false;
|
||||
HeadersError = false;
|
||||
IncorrectBigEndian = false;
|
||||
TooDeepDirs = false;
|
||||
SelfLinkedDirs = false;
|
||||
|
||||
UniqStartLocations.Clear();
|
||||
|
||||
Refs.Clear();
|
||||
_rootDir.Clear();
|
||||
VolDescs.Clear();
|
||||
|
||||
90
CPP/7zip/Archive/Iso/IsoIn.h
Executable file → Normal file
90
CPP/7zip/Archive/Iso/IsoIn.h
Executable file → Normal file
@@ -3,8 +3,8 @@
|
||||
#ifndef __ARCHIVE_ISO_IN_H
|
||||
#define __ARCHIVE_ISO_IN_H
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/MyCom.h"
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
@@ -25,37 +25,37 @@ struct CDir: public CDirRecord
|
||||
_subItems.Clear();
|
||||
}
|
||||
|
||||
int GetLength(bool checkSusp, int skipSize) const
|
||||
unsigned GetLen(bool checkSusp, unsigned skipSize) const
|
||||
{
|
||||
int len = GetLengthCur(checkSusp, skipSize);
|
||||
unsigned len = GetLenCur(checkSusp, skipSize);
|
||||
if (Parent != 0)
|
||||
if (Parent->Parent != 0)
|
||||
len += 1 + Parent->GetLength(checkSusp, skipSize);
|
||||
len += 1 + Parent->GetLen(checkSusp, skipSize);
|
||||
return len;
|
||||
}
|
||||
|
||||
int GetLengthU() const
|
||||
unsigned GetLenU() const
|
||||
{
|
||||
int len = (int)(FileId.GetCapacity() / 2);
|
||||
unsigned len = (unsigned)(FileId.Size() / 2);
|
||||
if (Parent != 0)
|
||||
if (Parent->Parent != 0)
|
||||
len += 1 + Parent->GetLengthU();
|
||||
len += 1 + Parent->GetLenU();
|
||||
return len;
|
||||
}
|
||||
|
||||
AString GetPath(bool checkSusp, int skipSize) const
|
||||
AString GetPath(bool checkSusp, unsigned skipSize) const
|
||||
{
|
||||
AString s;
|
||||
int len = GetLength(checkSusp, skipSize);
|
||||
char *p = s.GetBuffer(len + 1);
|
||||
unsigned len = GetLen(checkSusp, skipSize);
|
||||
char *p = s.GetBuffer(len);
|
||||
p += len;
|
||||
*p = 0;
|
||||
const CDir *cur = this;
|
||||
for (;;)
|
||||
{
|
||||
int curLen = cur->GetLengthCur(checkSusp, skipSize);
|
||||
unsigned curLen = cur->GetLenCur(checkSusp, skipSize);
|
||||
p -= curLen;
|
||||
memmove(p, (const char *)(const Byte *)cur->GetNameCur(checkSusp, skipSize), curLen);
|
||||
memcpy(p, (const char *)(const Byte *)cur->GetNameCur(checkSusp, skipSize), curLen);
|
||||
cur = cur->Parent;
|
||||
if (cur == 0)
|
||||
break;
|
||||
@@ -71,16 +71,16 @@ struct CDir: public CDirRecord
|
||||
UString GetPathU() const
|
||||
{
|
||||
UString s;
|
||||
int len = GetLengthU();
|
||||
wchar_t *p = s.GetBuffer(len + 1);
|
||||
unsigned len = GetLenU();
|
||||
wchar_t *p = s.GetBuffer(len);
|
||||
p += len;
|
||||
*p = 0;
|
||||
const CDir *cur = this;
|
||||
for (;;)
|
||||
{
|
||||
int curLen = (int)(cur->FileId.GetCapacity() / 2);
|
||||
unsigned curLen = (unsigned)(cur->FileId.Size() / 2);
|
||||
p -= curLen;
|
||||
for (int i = 0; i < curLen; i++)
|
||||
for (unsigned i = 0; i < curLen; i++)
|
||||
{
|
||||
Byte b0 = ((const Byte *)cur->FileId)[i * 2];
|
||||
Byte b1 = ((const Byte *)cur->FileId)[i * 2 + 1];
|
||||
@@ -163,23 +163,19 @@ struct CBootInitialEntry
|
||||
return SectorCount * 512;
|
||||
}
|
||||
|
||||
UString GetName() const
|
||||
AString GetName() const
|
||||
{
|
||||
UString s;
|
||||
if (Bootable)
|
||||
s += L"Bootable";
|
||||
AString s = (Bootable ? "Bootable" : "NotBootable");
|
||||
s += '_';
|
||||
if (BootMediaType < kNumBootMediaTypes)
|
||||
s += kMediaTypes[BootMediaType];
|
||||
else
|
||||
s += L"NotBootable";
|
||||
s += L"_";
|
||||
if (BootMediaType >= kNumBootMediaTypes)
|
||||
{
|
||||
wchar_t name[16];
|
||||
char name[16];
|
||||
ConvertUInt32ToString(BootMediaType, name);
|
||||
s += name;
|
||||
}
|
||||
else
|
||||
s += kMediaTypes[BootMediaType];
|
||||
s += L".img";
|
||||
s += ".img";
|
||||
return s;
|
||||
}
|
||||
};
|
||||
@@ -228,18 +224,19 @@ struct CVolumeDescriptor
|
||||
|
||||
struct CRef
|
||||
{
|
||||
CDir *Dir;
|
||||
const CDir *Dir;
|
||||
UInt32 Index;
|
||||
UInt32 NumExtents;
|
||||
UInt64 TotalSize;
|
||||
};
|
||||
|
||||
const UInt32 kBlockSize = 1 << 11;
|
||||
|
||||
class CInArchive
|
||||
{
|
||||
CMyComPtr<IInStream> _stream;
|
||||
IInStream *_stream;
|
||||
UInt64 _position;
|
||||
|
||||
Byte m_Buffer[kBlockSize];
|
||||
UInt32 m_BufferPos;
|
||||
|
||||
CDir _rootDir;
|
||||
@@ -275,15 +272,32 @@ public:
|
||||
HRESULT Open(IInStream *inStream);
|
||||
void Clear();
|
||||
|
||||
UInt64 _archiveSize;
|
||||
UInt64 _fileSize;
|
||||
UInt64 PhySize;
|
||||
|
||||
CRecordVector<CRef> Refs;
|
||||
CObjectVector<CVolumeDescriptor> VolDescs;
|
||||
int MainVolDescIndex;
|
||||
UInt32 BlockSize;
|
||||
CObjectVector<CBootInitialEntry> BootEntries;
|
||||
bool IncorrectBigEndian;
|
||||
|
||||
bool IsArc;
|
||||
bool UnexpectedEnd;
|
||||
bool HeadersError;
|
||||
bool IncorrectBigEndian;
|
||||
bool TooDeepDirs;
|
||||
bool SelfLinkedDirs;
|
||||
CRecordVector<UInt32> UniqStartLocations;
|
||||
|
||||
Byte m_Buffer[kBlockSize];
|
||||
|
||||
void UpdatePhySize(UInt32 blockIndex, UInt64 size)
|
||||
{
|
||||
UInt64 alignedSize = (size + BlockSize - 1) & ~((UInt64)BlockSize - 1);
|
||||
UInt64 end = blockIndex * BlockSize + alignedSize;
|
||||
if (PhySize < end)
|
||||
PhySize = end;
|
||||
}
|
||||
|
||||
bool IsJoliet() const { return VolDescs[MainVolDescIndex].IsJoliet(); }
|
||||
|
||||
@@ -297,17 +311,17 @@ public:
|
||||
size = (1440 << 10);
|
||||
else if (be.BootMediaType == NBootMediaType::k2d88Floppy)
|
||||
size = (2880 << 10);
|
||||
UInt64 startPos = be.LoadRBA * BlockSize;
|
||||
if (startPos < _archiveSize)
|
||||
UInt64 startPos = (UInt64)be.LoadRBA * BlockSize;
|
||||
if (startPos < _fileSize)
|
||||
{
|
||||
if (_archiveSize - startPos < size)
|
||||
size = _archiveSize - startPos;
|
||||
if (_fileSize - startPos < size)
|
||||
size = _fileSize - startPos;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
bool IsSusp;
|
||||
int SuspSkipSize;
|
||||
unsigned SuspSkipSize;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
62
CPP/7zip/Archive/Iso/IsoItem.h
Executable file → Normal file
62
CPP/7zip/Archive/Iso/IsoItem.h
Executable file → Normal file
@@ -3,11 +3,10 @@
|
||||
#ifndef __ARCHIVE_ISO_ITEM_H
|
||||
#define __ARCHIVE_ISO_ITEM_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/Buffer.h"
|
||||
#include "../../../Common/MyString.h"
|
||||
#include "../../../Common/MyBuffer.h"
|
||||
|
||||
#include "Windows/Time.h"
|
||||
#include "../../../Windows/TimeUtils.h"
|
||||
|
||||
#include "IsoHeader.h"
|
||||
|
||||
@@ -41,62 +40,77 @@ struct CRecordingDateTime
|
||||
|
||||
struct CDirRecord
|
||||
{
|
||||
Byte ExtendedAttributeRecordLen;
|
||||
UInt32 ExtentLocation;
|
||||
UInt32 DataLength;
|
||||
UInt32 Size;
|
||||
CRecordingDateTime DateTime;
|
||||
Byte FileFlags;
|
||||
Byte FileUnitSize;
|
||||
Byte InterleaveGapSize;
|
||||
Byte ExtendedAttributeRecordLen;
|
||||
UInt16 VolSequenceNumber;
|
||||
CByteBuffer FileId;
|
||||
CByteBuffer SystemUse;
|
||||
|
||||
bool IsDir() const { return (FileFlags & NFileFlags::kDirectory) != 0; }
|
||||
bool AreMultiPartEqualWith(const CDirRecord &a) const
|
||||
{
|
||||
return FileId == a.FileId
|
||||
&& (FileFlags & (~NFileFlags::kNonFinalExtent)) ==
|
||||
(a.FileFlags & (~NFileFlags::kNonFinalExtent));
|
||||
}
|
||||
|
||||
bool IsDir() const { return (FileFlags & NFileFlags::kDirectory) != 0; }
|
||||
bool IsNonFinalExtent() const { return (FileFlags & NFileFlags::kNonFinalExtent) != 0; }
|
||||
|
||||
bool IsSystemItem() const
|
||||
{
|
||||
if (FileId.GetCapacity() != 1)
|
||||
if (FileId.Size() != 1)
|
||||
return false;
|
||||
Byte b = *(const Byte *)FileId;
|
||||
return (b == 0 || b == 1);
|
||||
}
|
||||
|
||||
const Byte* FindSuspName(int skipSize, int &lenRes) const
|
||||
const Byte* FindSuspName(unsigned skipSize, unsigned &lenRes) const
|
||||
{
|
||||
lenRes = 0;
|
||||
if (SystemUse.Size() < skipSize)
|
||||
return 0;
|
||||
const Byte *p = (const Byte *)SystemUse + skipSize;
|
||||
int length = (int)(SystemUse.GetCapacity() - skipSize);
|
||||
while (length >= 5)
|
||||
unsigned rem = (unsigned)(SystemUse.Size() - skipSize);
|
||||
while (rem >= 5)
|
||||
{
|
||||
int len = p[2];
|
||||
unsigned len = p[2];
|
||||
if (len > rem)
|
||||
return 0;
|
||||
if (p[0] == 'N' && p[1] == 'M' && p[3] == 1)
|
||||
{
|
||||
if (len < 5)
|
||||
return 0; // Check it
|
||||
lenRes = len - 5;
|
||||
return p + 5;
|
||||
}
|
||||
p += len;
|
||||
length -= len;
|
||||
rem -= len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetLengthCur(bool checkSusp, int skipSize) const
|
||||
unsigned GetLenCur(bool checkSusp, int skipSize) const
|
||||
{
|
||||
if (checkSusp)
|
||||
{
|
||||
int len;
|
||||
unsigned len;
|
||||
const Byte *res = FindSuspName(skipSize, len);
|
||||
if (res != 0)
|
||||
return len;
|
||||
}
|
||||
return (int)FileId.GetCapacity();
|
||||
return (unsigned)FileId.Size();
|
||||
}
|
||||
|
||||
const Byte* GetNameCur(bool checkSusp, int skipSize) const
|
||||
{
|
||||
if (checkSusp)
|
||||
{
|
||||
int len;
|
||||
unsigned len;
|
||||
const Byte *res = FindSuspName(skipSize, len);
|
||||
if (res != 0)
|
||||
return res;
|
||||
@@ -105,7 +119,7 @@ struct CDirRecord
|
||||
}
|
||||
|
||||
|
||||
bool CheckSusp(const Byte *p, int &startPos) const
|
||||
bool CheckSusp(const Byte *p, unsigned &startPos) const
|
||||
{
|
||||
if (p[0] == 'S' &&
|
||||
p[1] == 'P' &&
|
||||
@@ -120,17 +134,17 @@ struct CDirRecord
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckSusp(int &startPos) const
|
||||
bool CheckSusp(unsigned &startPos) const
|
||||
{
|
||||
const Byte *p = (const Byte *)SystemUse;
|
||||
int length = (int)SystemUse.GetCapacity();
|
||||
const int kMinLen = 7;
|
||||
if (length < kMinLen)
|
||||
unsigned len = (int)SystemUse.Size();
|
||||
const unsigned kMinLen = 7;
|
||||
if (len < kMinLen)
|
||||
return false;
|
||||
if (CheckSusp(p, startPos))
|
||||
return true;
|
||||
const int kOffset2 = 14;
|
||||
if (length < kOffset2 + kMinLen)
|
||||
const unsigned kOffset2 = 14;
|
||||
if (len < kOffset2 + kMinLen)
|
||||
return false;
|
||||
return CheckSusp(p + kOffset2, startPos);
|
||||
}
|
||||
|
||||
14
CPP/7zip/Archive/Iso/IsoRegister.cpp
Executable file → Normal file
14
CPP/7zip/Archive/Iso/IsoRegister.cpp
Executable file → Normal file
@@ -5,9 +5,19 @@
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "IsoHandler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::NIso::CHandler; }
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
IMP_CreateArcIn
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"Iso", L"iso img", 0, 0xE7, { 'C', 'D', '0', '0', '1', 0x1 }, 7, false, CreateArc, 0 };
|
||||
{ "Iso", "iso img", 0, 0xE7,
|
||||
5, { 'C', 'D', '0', '0', '1' },
|
||||
NArchive::NIso::kStartPos + 1,
|
||||
0,
|
||||
CreateArc };
|
||||
|
||||
REGISTER_ARC(Iso)
|
||||
|
||||
}}
|
||||
|
||||
3
CPP/7zip/Archive/Iso/StdAfx.h
Executable file → Normal file
3
CPP/7zip/Archive/Iso/StdAfx.h
Executable file → Normal file
@@ -3,7 +3,6 @@
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/NewHandler.h"
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user