mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 12:07:03 -06:00
4.58 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
bd1fa36322
commit
3901bf0ab8
@@ -217,16 +217,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
size = (UInt32)rem;
|
||||
|
||||
RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL));
|
||||
UInt32 realProcessedSize;
|
||||
RINOK(ReadStream(_stream, sect, size, &realProcessedSize));
|
||||
size_t realProcessedSize = size;
|
||||
RINOK(ReadStream(_stream, sect, &realProcessedSize));
|
||||
if (realProcessedSize != size)
|
||||
break;
|
||||
|
||||
if (realOutStream)
|
||||
{
|
||||
RINOK(WriteStream(realOutStream, sect, size, &realProcessedSize));
|
||||
if (realProcessedSize != size)
|
||||
break;
|
||||
RINOK(WriteStream(realOutStream, sect, size));
|
||||
}
|
||||
pos += size;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ extern "C"
|
||||
#include "../../../../C/Alloc.h"
|
||||
}
|
||||
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
#include "Common/IntToString.h"
|
||||
@@ -19,22 +21,6 @@ namespace NCom{
|
||||
static const UInt32 kSignatureSize = 8;
|
||||
static const Byte kSignature[kSignatureSize] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 };
|
||||
|
||||
static HRESULT ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size)
|
||||
{
|
||||
UInt32 realProcessedSize;
|
||||
RINOK(ReadStream(inStream, data, size, &realProcessedSize));
|
||||
return (realProcessedSize == size) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
#ifdef LITTLE_ENDIAN_UNALIGN
|
||||
#define GetUi16(p) (*(const UInt16 *)(p))
|
||||
#define GetUi32(p) (*(const UInt32 *)(p))
|
||||
#else
|
||||
#define GetUi16(p) ((p)[0] | ((UInt16)(p)[1] << 8))
|
||||
#define GetUi32(p) ((p)[0] | ((UInt32)(p)[1] << 8) | ((UInt32)(p)[2] << 16) | ((UInt32)(p)[3] << 24))
|
||||
#endif
|
||||
|
||||
|
||||
void CUInt32Buf::Free()
|
||||
{
|
||||
MyFree(_buf);
|
||||
@@ -56,7 +42,7 @@ bool CUInt32Buf::Allocate(UInt32 numItems)
|
||||
static HRESULT ReadSector(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid)
|
||||
{
|
||||
RINOK(inStream->Seek((((UInt64)sid + 1) << sectorSizeBits), STREAM_SEEK_SET, NULL));
|
||||
return ReadBytes(inStream, buf, (UInt32)1 << sectorSizeBits);
|
||||
return ReadStream_FALSE(inStream, buf, (UInt32)1 << sectorSizeBits);
|
||||
}
|
||||
|
||||
static HRESULT ReadIDs(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid, UInt32 *dest)
|
||||
@@ -219,7 +205,7 @@ HRESULT OpenArchive(IInStream *inStream, CDatabase &db)
|
||||
{
|
||||
static const UInt32 kHeaderSize = 512;
|
||||
Byte p[kHeaderSize];
|
||||
RINOK(ReadBytes(inStream, p, kHeaderSize));
|
||||
RINOK(ReadStream_FALSE(inStream, p, kHeaderSize));
|
||||
if (memcmp(p, kSignature, kSignatureSize) != 0)
|
||||
return S_FALSE;
|
||||
UInt16 majorVer = GetUi16(p + 0x1A);
|
||||
|
||||
Reference in New Issue
Block a user