mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 04:07:08 -06:00
22.00
This commit is contained in:
123
CPP/7zip/Archive/7z/7zFolderInStream.cpp
Normal file → Executable file
123
CPP/7zip/Archive/7z/7zFolderInStream.cpp
Normal file → Executable file
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Windows/TimeUtils.h"
|
||||
|
||||
#include "7zFolderInStream.h"
|
||||
|
||||
namespace NArchive {
|
||||
@@ -13,17 +15,17 @@ void CFolderInStream::Init(IArchiveUpdateCallback *updateCallback,
|
||||
_updateCallback = updateCallback;
|
||||
_indexes = indexes;
|
||||
_numFiles = numFiles;
|
||||
_index = 0;
|
||||
|
||||
Processed.ClearAndReserve(numFiles);
|
||||
CRCs.ClearAndReserve(numFiles);
|
||||
Sizes.ClearAndReserve(numFiles);
|
||||
|
||||
_pos = 0;
|
||||
_crc = CRC_INIT_VAL;
|
||||
_size_Defined = false;
|
||||
_size = 0;
|
||||
|
||||
if (Need_CTime) CTimes.ClearAndReserve(numFiles);
|
||||
if (Need_ATime) ATimes.ClearAndReserve(numFiles);
|
||||
if (Need_MTime) MTimes.ClearAndReserve(numFiles);
|
||||
if (Need_Attrib) Attribs.ClearAndReserve(numFiles);
|
||||
TimesDefined.ClearAndReserve(numFiles);
|
||||
|
||||
_stream.Release();
|
||||
}
|
||||
|
||||
@@ -32,44 +34,101 @@ HRESULT CFolderInStream::OpenStream()
|
||||
_pos = 0;
|
||||
_crc = CRC_INIT_VAL;
|
||||
_size_Defined = false;
|
||||
_times_Defined = false;
|
||||
_size = 0;
|
||||
FILETIME_Clear(_cTime);
|
||||
FILETIME_Clear(_aTime);
|
||||
FILETIME_Clear(_mTime);
|
||||
_attrib = 0;
|
||||
|
||||
while (_index < _numFiles)
|
||||
while (Processed.Size() < _numFiles)
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> stream;
|
||||
HRESULT result = _updateCallback->GetStream(_indexes[_index], &stream);
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result != S_FALSE)
|
||||
return result;
|
||||
}
|
||||
const HRESULT result = _updateCallback->GetStream(_indexes[Processed.Size()], &stream);
|
||||
if (result != S_OK && result != S_FALSE)
|
||||
return result;
|
||||
|
||||
_stream = stream;
|
||||
|
||||
if (stream)
|
||||
{
|
||||
CMyComPtr<IStreamGetSize> streamGetSize;
|
||||
stream.QueryInterface(IID_IStreamGetSize, &streamGetSize);
|
||||
if (streamGetSize)
|
||||
{
|
||||
if (streamGetSize->GetSize(&_size) == S_OK)
|
||||
_size_Defined = true;
|
||||
CMyComPtr<IStreamGetProps> getProps;
|
||||
stream.QueryInterface(IID_IStreamGetProps, (void **)&getProps);
|
||||
if (getProps)
|
||||
{
|
||||
// access could be changed in first myx pass
|
||||
if (getProps->GetProps(&_size,
|
||||
Need_CTime ? &_cTime : NULL,
|
||||
Need_ATime ? &_aTime : NULL,
|
||||
Need_MTime ? &_mTime : NULL,
|
||||
Need_Attrib ? &_attrib : NULL)
|
||||
== S_OK)
|
||||
{
|
||||
_size_Defined = true;
|
||||
_times_Defined = true;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
{
|
||||
CMyComPtr<IStreamGetSize> streamGetSize;
|
||||
stream.QueryInterface(IID_IStreamGetSize, &streamGetSize);
|
||||
if (streamGetSize)
|
||||
{
|
||||
if (streamGetSize->GetSize(&_size) == S_OK)
|
||||
_size_Defined = true;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
_index++;
|
||||
RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
|
||||
AddFileInfo(result == S_OK);
|
||||
RINOK(AddFileInfo(result == S_OK));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CFolderInStream::AddFileInfo(bool isProcessed)
|
||||
static void AddFt(CRecordVector<UInt64> &vec, const FILETIME &ft)
|
||||
{
|
||||
Processed.Add(isProcessed);
|
||||
Sizes.Add(_pos);
|
||||
CRCs.Add(CRC_GET_DIGEST(_crc));
|
||||
vec.AddInReserved(FILETIME_To_UInt64(ft));
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT ReportItemProps(IArchiveUpdateCallbackArcProp *reportArcProp,
|
||||
UInt32 index, UInt64 size, const UInt32 *crc)
|
||||
{
|
||||
PROPVARIANT prop;
|
||||
prop.vt = VT_EMPTY;
|
||||
prop.wReserved1 = 0;
|
||||
|
||||
NWindows::NCOM::PropVarEm_Set_UInt64(&prop, size);
|
||||
RINOK(reportArcProp->ReportProp(NEventIndexType::kOutArcIndex, index, kpidSize, &prop));
|
||||
if (crc)
|
||||
{
|
||||
NWindows::NCOM::PropVarEm_Set_UInt32(&prop, *crc);
|
||||
RINOK(reportArcProp->ReportProp(NEventIndexType::kOutArcIndex, index, kpidCRC, &prop));
|
||||
}
|
||||
return reportArcProp->ReportFinished(NEventIndexType::kOutArcIndex, index, NUpdate::NOperationResult::kOK);
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT CFolderInStream::AddFileInfo(bool isProcessed)
|
||||
{
|
||||
// const UInt32 index = _indexes[Processed.Size()];
|
||||
Processed.AddInReserved(isProcessed);
|
||||
Sizes.AddInReserved(_pos);
|
||||
const UInt32 crc = CRC_GET_DIGEST(_crc);
|
||||
CRCs.AddInReserved(crc);
|
||||
TimesDefined.AddInReserved(_times_Defined);
|
||||
if (Need_CTime) AddFt(CTimes, _cTime);
|
||||
if (Need_ATime) AddFt(ATimes, _aTime);
|
||||
if (Need_MTime) AddFt(MTimes, _mTime);
|
||||
if (Need_Attrib) Attribs.AddInReserved(_attrib);
|
||||
/*
|
||||
if (isProcessed && _reportArcProp)
|
||||
RINOK(ReportItemProps(_reportArcProp, index, _pos, &crc))
|
||||
*/
|
||||
return _updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
@@ -95,18 +154,10 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz
|
||||
}
|
||||
|
||||
_stream.Release();
|
||||
_index++;
|
||||
AddFileInfo(true);
|
||||
|
||||
_pos = 0;
|
||||
_crc = CRC_INIT_VAL;
|
||||
_size_Defined = false;
|
||||
_size = 0;
|
||||
|
||||
RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
|
||||
RINOK(AddFileInfo(true));
|
||||
}
|
||||
|
||||
if (_index >= _numFiles)
|
||||
if (Processed.Size() >= _numFiles)
|
||||
break;
|
||||
RINOK(OpenStream());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user