Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-08-27 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:54 +0300
commit051769bbc577aeede90558b6ab5c9be187940ca0 (patch)
treee6330cb80f2d4a526d8aa27812528e053b0cda90 /CPP/7zip/Archive/Cpio
parent33ccab7e728a996800e166d849fe1e92a17e1afe (diff)
4.53 beta
Diffstat (limited to 'CPP/7zip/Archive/Cpio')
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.cpp182
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.h4
2 files changed, 66 insertions, 120 deletions
diff --git a/CPP/7zip/Archive/Cpio/CpioHandler.cpp b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
index 601afbd6..e2392b86 100755
--- a/CPP/7zip/Archive/Cpio/CpioHandler.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
@@ -3,6 +3,7 @@
#include "StdAfx.h"
#include "CpioHandler.h"
+#include "CpioIn.h"
#include "Common/Defs.h"
#include "Common/StringConvert.h"
@@ -16,8 +17,8 @@
#include "../../Common//LimitedStreams.h"
#include "../../Compress/Copy/CopyCoder.h"
+
#include "../Common/ItemNameUtils.h"
-#include "CpioIn.h"
using namespace NWindows;
using namespace NTime;
@@ -25,13 +26,15 @@ using namespace NTime;
namespace NArchive {
namespace NCpio {
+/*
enum // PropID
{
kpidinode = kpidUserDefined,
kpidiChkSum
};
+*/
-STATPROPSTG kProperties[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
{ NULL, kpidIsFolder, VT_BOOL},
@@ -44,43 +47,10 @@ STATPROPSTG kProperties[] =
// { L"CheckSum", kpidiChkSum, VT_UI4}
};
-STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
-{
- value->vt = VT_EMPTY;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
-{
- *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
- return E_INVALIDARG;
- const STATPROPSTG &srcItem = kProperties[index];
- *propID = srcItem.propid;
- *varType = srcItem.vt;
- *name = 0;
- return S_OK;
-}
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
-STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
-{
- *numProperties = 0;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 /* index */,
- BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
-{
- return E_INVALIDARG;
-}
-
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback *openArchiveCallback)
{
@@ -89,41 +59,41 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
{
CInArchive archive;
- if(archive.Open(inStream) != S_OK)
+ if (archive.Open(stream) != S_OK)
return S_FALSE;
- m_Items.Clear();
+ _items.Clear();
if (openArchiveCallback != NULL)
{
RINOK(openArchiveCallback->SetTotal(NULL, NULL));
- UInt64 numFiles = m_Items.Size();
+ UInt64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
}
for (;;)
{
- CItemEx itemInfo;
+ CItemEx item;
bool filled;
- HRESULT result = archive.GetNextItem(filled, itemInfo);
+ HRESULT result = archive.GetNextItem(filled, item);
if (result == S_FALSE)
return S_FALSE;
if (result != S_OK)
return S_FALSE;
if (!filled)
break;
- m_Items.Add(itemInfo);
- archive.SkeepDataRecords(itemInfo.Size, itemInfo.Align);
+ _items.Add(item);
+ archive.SkeepDataRecords(item.Size, item.Align);
if (openArchiveCallback != NULL)
{
- UInt64 numFiles = m_Items.Size();
+ UInt64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
}
}
- if (m_Items.Size() == 0)
+ if (_items.Size() == 0)
return S_FALSE;
- m_InStream = inStream;
+ _inStream = stream;
}
/*
catch(...)
@@ -137,35 +107,35 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close()
{
- m_Items.Clear();
- m_InStream.Release();
+ _items.Clear();
+ _inStream.Release();
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
- *numItems = m_Items.Size();
+ *numItems = _items.Size();
return S_OK;
}
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant propVariant;
- const CItemEx &item = m_Items[index];
+ NWindows::NCOM::CPropVariant prop;
+ const CItemEx &item = _items[index];
switch(propID)
{
case kpidPath:
- propVariant = (const wchar_t *)NItemName::GetOSName(
+ prop = (const wchar_t *)NItemName::GetOSName(
MultiByteToUnicodeString(item.Name, CP_OEMCP));
break;
case kpidIsFolder:
- propVariant = item.IsDirectory();
+ prop = item.IsDirectory();
break;
case kpidSize:
case kpidPackedSize:
- propVariant = item.Size;
+ prop = (UInt64)item.Size;
break;
case kpidLastWriteTime:
{
@@ -177,19 +147,19 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
utcFileTime.dwLowDateTime = 0;
utcFileTime.dwHighDateTime = 0;
}
- propVariant = utcFileTime;
+ prop = utcFileTime;
break;
}
+ /*
case kpidinode:
- propVariant = item.inode;
+ prop = item.inode;
break;
- /*
case kpidiChkSum:
- propVariant = item.ChkSum;
+ prop = item.ChkSum;
break;
*/
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
COM_TRY_END
}
@@ -198,89 +168,65 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
{
COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
bool allFilesMode = (numItems == UInt32(-1));
if (allFilesMode)
- numItems = m_Items.Size();
- if(numItems == 0)
+ numItems = _items.Size();
+ if (numItems == 0)
return S_OK;
- bool testMode = (_aTestMode != 0);
UInt64 totalSize = 0;
UInt32 i;
- for(i = 0; i < numItems; i++)
- totalSize += m_Items[allFilesMode ? i : indices[i]].Size;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
extractCallback->SetTotal(totalSize);
UInt64 currentTotalSize = 0;
UInt64 currentItemSize;
- CMyComPtr<ICompressCoder> copyCoder;
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
- for(i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
{
- RINOK(extractCallback->SetCompleted(&currentTotalSize));
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode;
- askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
Int32 index = allFilesMode ? i : indices[i];
- const CItemEx &itemInfo = m_Items[index];
-
+ const CItemEx &item = _items[index];
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
-
- currentItemSize = itemInfo.Size;
-
- if(itemInfo.IsDirectory())
+ currentItemSize = item.Size;
+ if (item.IsDirectory())
{
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
continue;
}
- if(!testMode && (!realOutStream))
- {
+ if (!testMode && (!realOutStream))
continue;
- }
RINOK(extractCallback->PrepareOperation(askMode));
+ if (testMode)
{
- if (testMode)
- {
- RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
- continue;
- }
-
- RINOK(m_InStream->Seek(itemInfo.GetDataPosition(), STREAM_SEEK_SET, NULL));
- CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
- CMyComPtr<ISequentialInStream> inStream(streamSpec);
- streamSpec->SetStream(m_InStream);
- streamSpec->Init(itemInfo.Size);
-
- CLocalProgress *localProgressSpec = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> progress = localProgressSpec;
- localProgressSpec->Init(extractCallback, false);
-
- CLocalCompressProgressInfo *localCompressProgressSpec =
- new CLocalCompressProgressInfo;
- CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
- localCompressProgressSpec->Init(progress,
- &currentTotalSize, &currentTotalSize);
-
- if(copyCoder == NULL)
- {
- copyCoder = new NCompress::CCopyCoder;
- }
- try
- {
- RINOK(copyCoder->Code(inStream, realOutStream,
- NULL, NULL, compressProgress));
- }
- catch(...)
- {
- realOutStream.Release();
- RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError));
- continue;
- }
- realOutStream.Release();
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
}
+ RINOK(_inStream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
}
return S_OK;
COM_TRY_END
diff --git a/CPP/7zip/Archive/Cpio/CpioHandler.h b/CPP/7zip/Archive/Cpio/CpioHandler.h
index e9320e61..3b4e7036 100755
--- a/CPP/7zip/Archive/Cpio/CpioHandler.h
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.h
@@ -21,8 +21,8 @@ public:
INTERFACE_IInArchive(;)
private:
- CObjectVector<CItemEx> m_Items;
- CMyComPtr<IInStream> m_InStream;
+ CObjectVector<CItemEx> _items;
+ CMyComPtr<IInStream> _inStream;
};
}}