9.04 beta

This commit is contained in:
Igor Pavlov
2009-06-02 00:00:00 +00:00
committed by Kornel Lesiński
parent 8874e4fbc9
commit 829409452d
440 changed files with 19803 additions and 9941 deletions

View File

@@ -46,9 +46,9 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
Close();
// try
{
if(_archive.Open(stream) != S_OK)
if (_archive.Open(stream) != S_OK)
return S_FALSE;
_inStream = stream;
_stream = stream;
}
// catch(...) { return S_FALSE; }
return S_OK;
@@ -58,7 +58,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
STDMETHODIMP CHandler::Close()
{
_archive.Clear();
_inStream.Release();
_stream.Release();
return S_OK;
}
@@ -160,7 +160,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
bool allFilesMode = (numItems == UInt32(-1));
if (allFilesMode)
numItems = _archive.Refs.Size();
if(numItems == 0)
if (numItems == 0)
return S_OK;
UInt64 totalSize = 0;
UInt32 i;
@@ -192,7 +192,10 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
CMyComPtr<ISequentialInStream> inStream(streamSpec);
streamSpec->SetStream(_inStream);
streamSpec->SetStream(_stream);
CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
{
@@ -211,7 +214,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())
if (item.IsDir())
{
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
@@ -231,16 +234,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if (!testMode && (!realOutStream))
continue;
RINOK(extractCallback->PrepareOperation(askMode));
if (testMode)
{
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
continue;
}
RINOK(_inStream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL));
streamSpec->Init(currentItemSize);
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
outStreamSpec->SetStream(realOutStream);
realOutStream.Release();
RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
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() ?
NArchive::NExtract::NOperationResult::kOK:
NArchive::NExtract::NOperationResult::kDataError));
}
@@ -248,4 +249,30 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
COM_TRY_END
}
STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
{
COM_TRY_BEGIN
*stream = 0;
UInt64 blockIndex;
UInt64 currentItemSize;
if (index < (UInt32)_archive.Refs.Size())
{
const CRef &ref = _archive.Refs[index];
const CDir &item = ref.Dir->_subItems[ref.Index];
if (item.IsDir())
return S_FALSE;
currentItemSize = item.DataLength;
blockIndex = item.ExtentLocation;
}
else
{
int bootIndex = index - _archive.Refs.Size();
const CBootInitialEntry &be = _archive.BootEntries[bootIndex];
currentItemSize = _archive.GetBootItemSize(bootIndex);
blockIndex = be.LoadRBA;
}
return CreateLimitedInStream(_stream, blockIndex * _archive.BlockSize, currentItemSize, stream);
COM_TRY_END
}
}}

View File

@@ -1,4 +1,4 @@
// Iso/Handler.h
// IsoHandler.h
#ifndef __ISO_HANDLER_H
#define __ISO_HANDLER_H
@@ -6,26 +6,23 @@
#include "Common/MyCom.h"
#include "../IArchive.h"
#include "IsoItem.h"
#include "IsoIn.h"
#include "IsoItem.h"
namespace NArchive {
namespace NIso {
class CHandler:
public IInArchive,
public IInArchiveGetStream,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP1(
IInArchive
)
INTERFACE_IInArchive(;)
private:
CMyComPtr<IInStream> _inStream;
CMyComPtr<IInStream> _stream;
CInArchive _archive;
public:
MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
INTERFACE_IInArchive(;)
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
};
}}

View File

@@ -3,9 +3,6 @@
#include "StdAfx.h"
#include "IsoIn.h"
#include "IsoHeader.h"
#include "Windows/Defs.h"
#include "../../Common/StreamUtils.h"
@@ -35,13 +32,13 @@ void CInArchive::ReadBytes(Byte *data, UInt32 size)
data[i] = ReadByte();
}
void CInArchive::Skeep(size_t size)
void CInArchive::Skip(size_t size)
{
while (size-- != 0)
ReadByte();
}
void CInArchive::SkeepZeros(size_t size)
void CInArchive::SkipZeros(size_t size)
{
while (size-- != 0)
{
@@ -174,8 +171,8 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
ReadBytes((Byte *)r.FileId, idLen);
int padSize = 1 - (idLen & 1);
// SkeepZeros(1 - (idLen & 1));
Skeep(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros
// SkipZeros(1 - (idLen & 1));
Skip(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros
int curPos = 33 + idLen + padSize;
if (curPos > len)
@@ -199,7 +196,7 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
d.VolFlags = ReadByte();
ReadBytes(d.SystemId, sizeof(d.SystemId));
ReadBytes(d.VolumeId, sizeof(d.VolumeId));
SkeepZeros(8);
SkipZeros(8);
d.VolumeSpaceSize = ReadUInt32();
ReadBytes(d.EscapeSequence, sizeof(d.EscapeSequence));
d.VolumeSetSize = ReadUInt16();
@@ -223,9 +220,9 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
ReadDateTime(d.ExpirationTime);
ReadDateTime(d.EffectiveTime);
d.FileStructureVersion = ReadByte(); // = 1
SkeepZeros(1);
SkipZeros(1);
ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse));
SkeepZeros(653);
SkipZeros(653);
}
static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
@@ -371,7 +368,7 @@ HRESULT CInArchive::Open2()
}
else
break;
SkeepZeros(0x800 - 7);
SkipZeros(0x800 - 7);
continue;
*/
}
@@ -382,7 +379,7 @@ HRESULT CInArchive::Open2()
if (sig[0] == NVolDescType::kTerminator)
{
break;
// Skeep(0x800 - 7);
// Skip(0x800 - 7);
// continue;
}
switch(sig[0])

View File

@@ -3,13 +3,13 @@
#ifndef __ARCHIVE_ISO_IN_H
#define __ARCHIVE_ISO_IN_H
#include "Common/MyCom.h"
#include "Common/IntToString.h"
#include "Common/MyCom.h"
#include "../../IStream.h"
#include "IsoItem.h"
#include "IsoHeader.h"
#include "IsoItem.h"
namespace NArchive {
namespace NIso {
@@ -159,8 +159,8 @@ struct CBootInitialEntry
s += L"_";
if (BootMediaType >= kNumBootMediaTypes)
{
wchar_t name[32];
ConvertUInt64ToString(BootMediaType, name);
wchar_t name[16];
ConvertUInt32ToString(BootMediaType, name);
s += name;
}
else
@@ -232,8 +232,8 @@ class CInArchive
bool _bootIsDefined;
CBootRecordDescriptor _bootDesc;
void Skeep(size_t size);
void SkeepZeros(size_t size);
void Skip(size_t size);
void SkipZeros(size_t size);
Byte ReadByte();
void ReadBytes(Byte *data, UInt32 size);
UInt16 ReadUInt16Spec();