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>2009-06-02 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:59 +0300
commit829409452d85cd6dd9dfc9151f109d6e13a2bb1c (patch)
treee0acaea47044d167f35fa197584dee1bde41c329 /CPP/7zip/UI/Agent
parent8874e4fbc9faabdcff719b9b2ac8ebad4f282bbe (diff)
9.04 beta
Diffstat (limited to 'CPP/7zip/UI/Agent')
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.cpp136
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.h28
-rwxr-xr-xCPP/7zip/UI/Agent/AgentOut.cpp45
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.cpp130
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.h26
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolder.cpp26
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOpen.cpp6
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOut.cpp37
-rwxr-xr-xCPP/7zip/UI/Agent/IFolderArchive.h13
-rwxr-xr-xCPP/7zip/UI/Agent/UpdateCallbackAgent.cpp16
10 files changed, 211 insertions, 252 deletions
diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp
index 0b57049c..0b8f7c37 100755
--- a/CPP/7zip/UI/Agent/Agent.cpp
+++ b/CPP/7zip/UI/Agent/Agent.cpp
@@ -2,23 +2,14 @@
#include "StdAfx.h"
-#include "Common/StringConvert.h"
+#include "../../../../C/Sort.h"
+
#include "Common/ComTry.h"
-#include "Windows/Defs.h"
-#include "Windows/PropVariant.h"
-#include "Windows/FileFind.h"
-#include "../Common/DefaultName.h"
#include "../Common/ArchiveExtractCallback.h"
#include "Agent.h"
-extern "C"
-{
- #include "../../../../C/Sort.h"
-}
-
-
using namespace NWindows;
STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
@@ -46,7 +37,6 @@ void CAgentFolder::LoadFolder(CProxyFolder *folder)
}
}
-
STDMETHODIMP CAgentFolder::LoadItems()
{
if (!_agentSpec->_archiveLink.IsOpen)
@@ -238,6 +228,40 @@ STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
COM_TRY_END
}
+STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ CMyComPtr<IInArchiveGetStream> getStream;
+ _agentSpec->GetArchive()->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream);
+ if (!getStream)
+ return S_OK;
+
+ const CProxyFolder *folder;
+ UInt32 realIndex;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[index];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = index;
+ }
+
+ UInt32 indexInArchive;
+ if (realIndex < (UInt32)folder->Folders.Size())
+ {
+ const CProxyFolder &item = folder->Folders[realIndex];
+ if (!item.IsLeaf)
+ return S_OK;
+ indexInArchive = item.Index;
+ }
+ else
+ indexInArchive = folder->Files[realIndex - folder->Folders.Size()].Index;
+ return getStream->GetStream(indexInArchive, stream);
+}
+
STATPROPSTG kProperties[] =
{
{ NULL, kpidNumSubDirs, VT_UI4},
@@ -261,6 +285,8 @@ STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProperties)
*numProperties += kNumProperties;
if (!_flatMode)
(*numProperties)--;
+ if (!_agentSpec->_proxyArchive->ThereIsPathProp)
+ (*numProperties)++;
return S_OK;
COM_TRY_END
}
@@ -270,6 +296,18 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
COM_TRY_BEGIN
UInt32 numProperties;
_agentSpec->GetArchive()->GetNumberOfProperties(&numProperties);
+ if (!_agentSpec->_proxyArchive->ThereIsPathProp)
+ {
+ if (index == 0)
+ {
+ *propID = kpidName;
+ *varType = VT_BSTR;
+ *name = 0;
+ return S_OK;
+ }
+ index--;
+ }
+
if (index < numProperties)
{
RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType));
@@ -378,7 +416,7 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
NExtract::NPathMode::EEnum pathMode,
NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
- INT32 testMode,
+ Int32 testMode,
IFolderArchiveExtractCallback *extractCallback2)
{
COM_TRY_BEGIN
@@ -399,17 +437,12 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
- extractCallbackSpec->Init(_agentSpec->GetArchive(),
+ extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
extractCallback2,
- false,
+ false, testMode ? true : false, false,
(path ? path : L""),
pathParts,
- _agentSpec->DefaultName,
- _agentSpec->DefaultTime,
- _agentSpec->DefaultAttrib,
- (UInt64)(Int64)-1
- // ,_agentSpec->_srcDirectoryPrefix
- );
+ (UInt64)(Int64)-1);
CUIntVector realIndices;
GetRealIndices(indices, numItems, realIndices);
return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
@@ -433,18 +466,21 @@ CAgent::~CAgent()
}
STDMETHODIMP CAgent::Open(
+ IInStream *inStream,
const wchar_t *filePath,
BSTR *archiveType,
- // CLSID *clsIDResult,
IArchiveOpenCallback *openArchiveCallback)
{
COM_TRY_BEGIN
_archiveFilePath = filePath;
- NFile::NFind::CFileInfoW fileInfo;
- if (!NFile::NFind::FindFile(_archiveFilePath, fileInfo))
- return ::GetLastError();
- if (fileInfo.IsDir())
- return E_FAIL;
+ NFile::NFind::CFileInfoW fi;
+ if (!inStream)
+ {
+ if (!fi.Find(_archiveFilePath))
+ return ::GetLastError();
+ if (fi.IsDir())
+ return E_FAIL;
+ }
CArcInfoEx archiverInfo0, archiverInfo1;
_compressCodecsInfo.Release();
@@ -452,14 +488,16 @@ STDMETHODIMP CAgent::Open(
_compressCodecsInfo = _codecs;
RINOK(_codecs->Load());
- RINOK(OpenArchive(_codecs, CIntVector(), _archiveFilePath, _archiveLink, openArchiveCallback));
- // _archive = _archiveLink.GetArchive();
- DefaultName = _archiveLink.GetDefaultItemName();
- const CArcInfoEx &ai = _codecs->Formats[_archiveLink.GetArchiverIndex()];
+ RINOK(_archiveLink.Open(_codecs, CIntVector(), false, inStream, _archiveFilePath, openArchiveCallback));
- DefaultTime = fileInfo.MTime;
- DefaultAttrib = fileInfo.Attrib;
- ArchiveType = ai.Name;
+ CArc &arc = _archiveLink.Arcs.Back();
+ if (!inStream)
+ {
+ arc.MTimeDefined = !fi.IsDevice;
+ arc.MTime = fi.MTime;
+ }
+
+ ArchiveType = _codecs->Formats[arc.FormatIndex].Name;
if (archiveType == 0)
return S_OK;
return StringToBstr(ArchiveType, archiveType);
@@ -474,7 +512,7 @@ STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback)
delete _proxyArchive;
_proxyArchive = NULL;
}
- RINOK(ReOpenArchive(_codecs, _archiveLink, _archiveFilePath, openArchiveCallback));
+ RINOK(_archiveLink.ReOpen(_codecs, _archiveFilePath, openArchiveCallback));
return ReadItems();
COM_TRY_END
}
@@ -482,13 +520,7 @@ STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback)
STDMETHODIMP CAgent::Close()
{
COM_TRY_BEGIN
- RINOK(_archiveLink.Close());
- if (_archiveLink.GetNumLevels() > 1)
- {
- // return S_OK;
- }
- // _archive->Close();
- return S_OK;
+ return _archiveLink.Close();
COM_TRY_END
}
@@ -504,11 +536,7 @@ HRESULT CAgent::ReadItems()
if (_proxyArchive != NULL)
return S_OK;
_proxyArchive = new CProxyArchive();
- return _proxyArchive->Load(GetArchive(),
- DefaultName,
- // _defaultTime,
- // _defaultAttrib,
- NULL);
+ return _proxyArchive->Load(GetArc(), NULL);
}
STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
@@ -528,24 +556,19 @@ STDMETHODIMP CAgent::Extract(
NExtract::NPathMode::EEnum pathMode,
NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
- INT32 testMode,
+ Int32 testMode,
IFolderArchiveExtractCallback *extractCallback2)
{
COM_TRY_BEGIN
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
- extractCallbackSpec->Init(GetArchive(),
+ extractCallbackSpec->Init(NULL, &GetArc(),
extractCallback2,
- false,
+ false, testMode ? true : false, false,
path,
UStringVector(),
- DefaultName,
- DefaultTime,
- DefaultAttrib,
- (UInt64)(Int64)-1
- // ,_srcDirectoryPrefix
- );
+ (UInt64)(Int64)-1);
return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
COM_TRY_END
}
@@ -590,4 +613,3 @@ STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index,
name, propID, varType);
COM_TRY_END
}
-
diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h
index 64fb31f6..b95725e4 100755
--- a/CPP/7zip/UI/Agent/Agent.h
+++ b/CPP/7zip/UI/Agent/Agent.h
@@ -4,19 +4,20 @@
#define __AGENT_AGENT_H
#include "Common/MyCom.h"
+
#include "Windows/PropVariant.h"
-#include "../Common/UpdateAction.h"
#include "../Common/OpenArchive.h"
-
-#include "IFolderArchive.h"
-#include "AgentProxy.h"
+#include "../Common/UpdateAction.h"
#ifdef NEW_FOLDER_INTERFACE
#include "../FileManager/IFolder.h"
#include "../Common/LoadCodecs.h"
#endif
+#include "AgentProxy.h"
+#include "IFolderArchive.h"
+
class CAgentFolder;
DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC)
@@ -38,6 +39,7 @@ class CAgentFolder:
public IGetFolderArchiveProperties,
public IArchiveFolder,
public IArchiveFolderInternal,
+ public IInArchiveGetStream,
#ifdef NEW_FOLDER_INTERFACE
public IFolderOperations,
public IFolderSetFlatMode,
@@ -52,6 +54,7 @@ public:
MY_QUERYINTERFACE_ENTRY(IGetFolderArchiveProperties)
MY_QUERYINTERFACE_ENTRY(IArchiveFolder)
MY_QUERYINTERFACE_ENTRY(IArchiveFolderInternal)
+ MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
#ifdef NEW_FOLDER_INTERFACE
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
@@ -73,11 +76,13 @@ public:
NExtract::NPathMode::EEnum pathMode,
NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
- INT32 testMode,
+ Int32 testMode,
IFolderArchiveExtractCallback *extractCallback);
STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder);
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+
#ifdef NEW_FOLDER_INTERFACE
INTERFACE_FolderOperations(;)
@@ -170,7 +175,7 @@ public:
IFolderArchiveUpdateCallback *updateCallback100);
// ISetProperties
- STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, INT32 numProperties);
+ STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
#endif
CCodecs *_codecs;
@@ -182,14 +187,8 @@ private:
HRESULT ReadItems();
public:
CProxyArchive *_proxyArchive;
-
CArchiveLink _archiveLink;
- // IInArchive *_archive2;
-
- UString DefaultName;
- FILETIME DefaultTime;
- DWORD DefaultAttrib;
UString ArchiveType;
@@ -206,8 +205,9 @@ public:
CObjectVector<NWindows::NCOM::CPropVariant> m_PropValues;
#endif
- IInArchive *GetArchive() { return _archiveLink.GetArchive(); }
- bool CanUpdate() const { return _archiveLink.GetNumLevels() <= 1; }
+ const CArc &GetArc() { return _archiveLink.Arcs.Back(); }
+ IInArchive *GetArchive() { return GetArc().Archive; }
+ bool CanUpdate() const { return _archiveLink.Arcs.Size() == 1; }
};
#ifdef NEW_FOLDER_INTERFACE
diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp
index ffeac1c6..51a5affa 100755
--- a/CPP/7zip/UI/Agent/AgentOut.cpp
+++ b/CPP/7zip/UI/Agent/AgentOut.cpp
@@ -27,12 +27,6 @@
using namespace NWindows;
using namespace NCOM;
-static HRESULT CopyBlock(ISequentialInStream *inStream, ISequentialOutStream *outStream)
-{
- CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
- return copyCoder->Code(inStream, outStream, NULL, NULL, NULL);
-}
-
STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
{
_archiveNamePrefix.Empty();
@@ -86,20 +80,6 @@ STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
return S_OK;
}
-
-static HRESULT GetFileTime(CAgent *agent, UInt32 itemIndex, FILETIME &fileTime)
-{
- CPropVariant property;
- RINOK(agent->GetArchive()->GetProperty(itemIndex, kpidMTime, &property));
- if (property.vt == VT_FILETIME)
- fileTime = property.filetime;
- else if (property.vt == VT_EMPTY)
- fileTime = agent->DefaultTime;
- else
- throw 4190407;
- return S_OK;
-}
-
static HRESULT EnumerateArchiveItems(CAgent *agent,
const CProxyFolder &item,
const UString &prefix,
@@ -110,8 +90,7 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
{
const CProxyFile &fileItem = item.Files[i];
CArcItem ai;
-
- RINOK(::GetFileTime(agent, fileItem.Index, ai.MTime));
+ RINOK(agent->GetArc().GetItemMTime(fileItem.Index, ai.MTime, ai.MTimeDefined));
CPropVariant property;
agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property);
@@ -128,10 +107,10 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
{
const CProxyFolder &dirItem = item.Folders[i];
UString fullName = prefix + dirItem.Name;
- if(dirItem.IsLeaf)
+ if (dirItem.IsLeaf)
{
CArcItem ai;
- RINOK(::GetFileTime(agent, dirItem.Index, ai.MTime));
+ RINOK(agent->GetArc().GetItemMTime(dirItem.Index, ai.MTime, ai.MTimeDefined));
ai.IsDir = true;
ai.SizeDefined = false;
ai.Name = fullName;
@@ -149,7 +128,7 @@ struct CAgUpCallbackImp: public IUpdateProduceCallback
const CObjectVector<CArcItem> *_arcItems;
IFolderArchiveUpdateCallback *_callback;
- CAgUpCallbackImp(const CObjectVector<CArcItem> *a,
+ CAgUpCallbackImp(const CObjectVector<CArcItem> *a,
IFolderArchiveUpdateCallback *callback): _arcItems(a), _callback(callback) {}
HRESULT ShowDeleteFile(int arcIndex);
};
@@ -268,7 +247,7 @@ STDMETHODIMP CAgent::DoOperation(
{
UString resultPath;
int pos;
- if(!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
+ if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
return E_FAIL;
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
}
@@ -316,7 +295,7 @@ STDMETHODIMP CAgent::DoOperation(
if (!sfxStreamSpec->Open(sfxModule))
return E_FAIL;
// throw "Can't open sfx module";
- RINOK(CopyBlock(sfxStream, outStream));
+ RINOK(NCompress::CopyStream(sfxStream, outStream, NULL));
}
RINOK(outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback));
@@ -350,7 +329,7 @@ HRESULT CAgent::CommonUpdate(
{
UString resultPath;
int pos;
- if(!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
+ if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
throw 141716;
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
}
@@ -362,8 +341,8 @@ HRESULT CAgent::CommonUpdate(
resultName = newArchiveName;
if (i > 0)
{
- wchar_t s[32];
- ConvertUInt64ToString(i, s);
+ wchar_t s[16];
+ ConvertUInt32ToString(i, s);
resultName += s;
}
if (outStreamSpec->Open(realPath))
@@ -515,11 +494,11 @@ HRESULT CAgent::RenameItem(
CUpdatePair2 up2;
up2.NewData = false;
up2.NewProps = true;
- RINOK(IsArchiveItemAnti(GetArchive(), i, up2.IsAnti));
+ RINOK(GetArc().IsItemAnti(i, up2.IsAnti));
up2.ArcIndex = i;
UString oldFullPath;
- RINOK(GetArchiveItemPath(GetArchive(), i, DefaultName, oldFullPath));
+ RINOK(GetArc().GetItemPath(i, oldFullPath));
if (oldItemPath.CompareNoCase(oldFullPath.Left(oldItemPath.Length())) != 0)
return E_INVALIDARG;
@@ -543,7 +522,7 @@ HRESULT CAgent::RenameItem(
}
STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
- const PROPVARIANT *values, INT32 numProperties)
+ const PROPVARIANT *values, Int32 numProperties)
{
m_PropNames.Clear();
m_PropValues.Clear();
diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp
index 0a2de592..9686cf34 100755
--- a/CPP/7zip/UI/Agent/AgentProxy.cpp
+++ b/CPP/7zip/UI/Agent/AgentProxy.cpp
@@ -2,18 +2,14 @@
#include "StdAfx.h"
-#include "AgentProxy.h"
+#include "../../../../C/Sort.h"
-#include "Common/MyCom.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
-#include "Windows/Defs.h"
+
#include "../Common/OpenArchive.h"
-extern "C"
-{
- #include "../../../../C/Sort.h"
-}
+#include "AgentProxy.h"
using namespace NWindows;
@@ -58,7 +54,7 @@ CProxyFolder* CProxyFolder::AddDirSubItem(UInt32 index, bool leaf, const UString
if (folderIndex >= 0)
{
CProxyFolder *item = &Folders[folderIndex];
- if(leaf)
+ if (leaf)
{
item->Index = index;
item->IsLeaf = true;
@@ -116,16 +112,16 @@ void CProxyFolder::AddRealIndices(CUIntVector &realIndices) const
if (IsLeaf)
realIndices.Add(Index);
int i;
- for(i = 0; i < Folders.Size(); i++)
+ for (i = 0; i < Folders.Size(); i++)
Folders[i].AddRealIndices(realIndices);
- for(i = 0; i < Files.Size(); i++)
+ for (i = 0; i < Files.Size(); i++)
realIndices.Add(Files[i].Index);
}
void CProxyFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const
{
realIndices.Clear();
- for(UInt32 i = 0; i < numItems; i++)
+ for (UInt32 i = 0; i < numItems; i++)
{
int index = indices[i];
int numDirItems = Folders.Size();
@@ -140,24 +136,6 @@ void CProxyFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntV
///////////////////////////////////////////////
// CProxyArchive
-HRESULT CProxyArchive::Reload(IInArchive *archive, IProgress *progress)
-{
- RootFolder.Clear();
- return ReadObjects(archive, progress);
-}
-
-HRESULT CProxyArchive::Load(IInArchive *archive,
- const UString &defaultName,
- // const FILETIME &defaultTime,
- // UInt32 defaultAttributes,
- IProgress *progress)
-{
- DefaultName = defaultName;
- // DefaultTime = defaultTime;
- // DefaultAttributes = defaultAttributes;
- return Reload(archive, progress);
-}
-
static UInt64 GetSize(IInArchive *archive, UInt32 index, PROPID propID)
{
NCOM::CPropVariant prop;
@@ -182,13 +160,8 @@ void CProxyFolder::CalculateSizes(IInArchive *archive)
PackSize += GetSize(archive, index, kpidPackSize);
{
NCOM::CPropVariant prop;
- if (archive->GetProperty(index, kpidCRC, &prop) == S_OK)
- {
- if (prop.vt == VT_UI4)
- Crc += prop.ulVal;
- else
- CrcIsDefined = false;
- }
+ if (archive->GetProperty(index, kpidCRC, &prop) == S_OK && prop.vt == VT_UI4)
+ Crc += prop.ulVal;
else
CrcIsDefined = false;
}
@@ -207,70 +180,67 @@ void CProxyFolder::CalculateSizes(IInArchive *archive)
}
}
-HRESULT CProxyArchive::ReadObjects(IInArchive *archive, IProgress *progress)
+HRESULT CProxyArchive::Load(const CArc &arc, IProgress *progress)
{
+ RootFolder.Clear();
+ IInArchive *archive = arc.Archive;
+ {
+ ThereIsPathProp = false;
+ UInt32 numProps;
+ archive->GetNumberOfProperties(&numProps);
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE varType;
+ RINOK(archive->GetPropertyInfo(i, &name, &propID, &varType));
+ if (propID == kpidPath)
+ {
+ ThereIsPathProp = true;
+ break;
+ }
+ }
+ }
+
UInt32 numItems;
RINOK(archive->GetNumberOfItems(&numItems));
if (progress != NULL)
{
- UINT64 totalItems = numItems;
+ UInt64 totalItems = numItems;
RINOK(progress->SetTotal(totalItems));
}
- for(UInt32 i = 0; i < numItems; i++)
+ UString fileName;
+ for (UInt32 i = 0; i < numItems; i++)
{
- if (progress != NULL)
+ if (progress != NULL && (i & 0xFFFFF) == 0)
{
- UINT64 currentItemIndex = i;
+ UInt64 currentItemIndex = i;
RINOK(progress->SetCompleted(&currentItemIndex));
}
- NCOM::CPropVariant propVariantPath;
- RINOK(archive->GetProperty(i, kpidPath, &propVariantPath));
- CProxyFolder *currentItem = &RootFolder;
- UString fileName;
- if(propVariantPath.vt == VT_EMPTY)
+ UString filePath;
+ RINOK(arc.GetItemPath(i, filePath));
+ CProxyFolder *curItem = &RootFolder;
+ int len = filePath.Length();
+ fileName.Empty();
+ for (int j = 0; j < len; j++)
{
- fileName = DefaultName;
-
- NCOM::CPropVariant prop;
- RINOK(archive->GetProperty(i, kpidExtension, &prop));
- if (prop.vt == VT_BSTR)
+ wchar_t c = filePath[j];
+ if (c == WCHAR_PATH_SEPARATOR || c == L'/')
{
- fileName += L'.';
- fileName += prop.bstrVal;
- }
- else if (prop.vt != VT_EMPTY)
- return E_FAIL;
-
- }
- else
- {
- if(propVariantPath.vt != VT_BSTR)
- return E_FAIL;
- UString filePath = propVariantPath.bstrVal;
-
- int len = filePath.Length();
- for (int i = 0; i < len; i++)
- {
- wchar_t c = filePath[i];
- if (c == WCHAR_PATH_SEPARATOR || c == L'/')
- {
- currentItem = currentItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName);
- fileName.Empty();
- }
- else
- fileName += c;
+ curItem = curItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName);
+ fileName.Empty();
}
+ else
+ fileName += c;
}
- NCOM::CPropVariant propVariantIsFolder;
bool isFolder;
RINOK(IsArchiveItemFolder(archive, i, isFolder));
- if(isFolder)
- currentItem->AddDirSubItem(i, true, fileName);
+ if (isFolder)
+ curItem->AddDirSubItem(i, true, fileName);
else
- currentItem->AddFileSubItem(i, fileName);
+ curItem->AddFileSubItem(i, fileName);
}
RootFolder.CalculateSizes(archive);
return S_OK;
}
-
diff --git a/CPP/7zip/UI/Agent/AgentProxy.h b/CPP/7zip/UI/Agent/AgentProxy.h
index a0111088..d4caca16 100755
--- a/CPP/7zip/UI/Agent/AgentProxy.h
+++ b/CPP/7zip/UI/Agent/AgentProxy.h
@@ -5,18 +5,16 @@
#include "Common/MyString.h"
-#include "../../Archive/IArchive.h"
+#include "../Common/OpenArchive.h"
-class CProxyFile
+struct CProxyFile
{
-public:
UInt32 Index;
UString Name;
};
-class CProxyFolder: public CProxyFile
+struct CProxyFolder: public CProxyFile
{
-public:
CProxyFolder *Parent;
CObjectVector<CProxyFolder> Folders;
CObjectVector<CProxyFile> Files;
@@ -44,20 +42,12 @@ public:
void CalculateSizes(IInArchive *archive);
};
-class CProxyArchive
+struct CProxyArchive
{
- HRESULT ReadObjects(IInArchive *archive, IProgress *progress);
-public:
- UString DefaultName;
- // FILETIME DefaultTime;
- // UInt32 DefaultAttributes;
CProxyFolder RootFolder;
- HRESULT Reload(IInArchive *archive, IProgress *progress);
- HRESULT Load(IInArchive *archive,
- const UString &defaultName,
- // const FILETIME &defaultTime,
- // UInt32 defaultAttributes,
- IProgress *progress);
+ bool ThereIsPathProp;
+
+ HRESULT Load(const CArc &arc, IProgress *progress);
};
-#endif \ No newline at end of file
+#endif
diff --git a/CPP/7zip/UI/Agent/ArchiveFolder.cpp b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
index 780d26b8..57975e7d 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolder.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
@@ -1,17 +1,9 @@
-// Zip/ArchiveFolder.cpp
+// Agent/ArchiveFolder.cpp
#include "StdAfx.h"
#include "Common/ComTry.h"
-#include "Common/StringConvert.h"
-#include "Windows/Defs.h"
-#include "Windows/PropVariant.h"
-#include "Windows/PropVariantConversions.h"
-#include "Windows/FileDir.h"
-#include "../../Common/FileStreams.h"
-
-#include "../Common/UpdatePair.h"
#include "../Common/ArchiveExtractCallback.h"
#include "Agent.h"
@@ -19,7 +11,7 @@
using namespace NWindows;
using namespace NCOM;
-STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
+STDMETHODIMP CAgentFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
COM_TRY_BEGIN
@@ -46,18 +38,12 @@ STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
NExtract::NPathMode::kCurrentPathnames;
extractCallbackSpec->InitForMulti(false, pathMode, NExtract::NOverwriteMode::kAskBefore);
- extractCallbackSpec->Init(_agentSpec->GetArchive(),
+ extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
extractCallback2,
- false,
+ false, false, false,
path,
pathParts,
- _agentSpec->DefaultName,
- _agentSpec->DefaultTime,
- _agentSpec->DefaultAttrib,
- (UInt64)(Int64)-1
-
- // ,_agentSpec->_srcDirectoryPrefix
- );
+ (UInt64)(Int64)-1);
CUIntVector realIndices;
GetRealIndices(indices, numItems, realIndices);
return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
@@ -65,7 +51,7 @@ STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
COM_TRY_END
}
-STDMETHODIMP CAgentFolder::MoveTo(const UINT32 * /* indices */, UINT32 /* numItems */,
+STDMETHODIMP CAgentFolder::MoveTo(const UInt32 * /* indices */, UInt32 /* numItems */,
const wchar_t * /* path */, IFolderOperationsExtractCallback * /* callback */)
{
return E_NOTIMPL;
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
index f339a287..98c75f4d 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
@@ -6,8 +6,6 @@
#include "Common/StringConvert.h"
-#include "../Common/OpenArchive.h"
-
static inline UINT GetCurrentFileCodePage()
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
@@ -28,7 +26,7 @@ int CArchiveFolderManager::FindFormat(const UString &type)
return -1;
}
-STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath,
+STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream, const wchar_t *filePath,
IFolderFolder **resultFolder, IProgress *progress)
{
CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
@@ -39,7 +37,7 @@ STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath,
}
CAgent *agent = new CAgent();
CMyComPtr<IInFolderArchive> archive = agent;
- RINOK(agent->Open(filePath, NULL, openArchiveCallback));
+ RINOK(agent->Open(inStream, filePath, NULL, openArchiveCallback));
return agent->BindToRootFolder(resultFolder);
}
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
index 304dce83..8f03f44d 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
@@ -1,17 +1,15 @@
// FolderOut.cpp
#include "StdAfx.h"
-#include "Agent.h"
-#include "Common/StringConvert.h"
#include "Common/ComTry.h"
+
#include "Windows/FileDir.h"
-// #include "../Common/CompressEngineCommon.h"
-#include "../Common/ZipRegistry.h"
-#include "../Common/UpdateAction.h"
#include "../Common/WorkDir.h"
+#include "Agent.h"
+
using namespace NWindows;
using namespace NFile;
using namespace NDirectory;
@@ -35,7 +33,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
NWorkDir::CInfo workDirInfo;
ReadWorkDirInfo(workDirInfo);
UString archiveFilePath = _agentSpec->_archiveFilePath;
- UString workDir = GetWorkDir(workDirInfo, archiveFilePath );
+ UString workDir = GetWorkDir(workDirInfo, archiveFilePath);
CreateComplexDirectory(workDir);
CTempFileW tempFile;
@@ -86,11 +84,12 @@ HRESULT CAgentFolder::CommonUpdateOperation(
// m_FolderItem = NULL;
- if (!DeleteFileAlways(archiveFilePath ))
- return GetLastError();
+ if (NFind::DoesFileExist(archiveFilePath))
+ if (!DeleteFileAlways(archiveFilePath))
+ return GetLastError();
tempFile.DisableDeleting();
- if (!MyMoveFile(tempFileName, archiveFilePath ))
+ if (!MyMoveFile(tempFileName, archiveFilePath))
return GetLastError();
{
@@ -134,17 +133,23 @@ STDMETHODIMP CAgentFolder::CopyFrom(
IProgress *progress)
{
COM_TRY_BEGIN
- RINOK(_agentSpec->SetFiles(fromFolderPath, itemsPaths, numItems));
- RINOK(_agentSpec->SetFolder(this));
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
if (progress != 0)
{
- CMyComPtr<IProgress> progressWrapper = progress;
- RINOK(progressWrapper.QueryInterface(
- IID_IFolderArchiveUpdateCallback, &updateCallback100));
+ RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&updateCallback100));
+ }
+ try
+ {
+ RINOK(_agentSpec->SetFiles(fromFolderPath, itemsPaths, numItems));
+ RINOK(_agentSpec->SetFolder(this));
+ return CommonUpdateOperation(false, false, false, NULL,
+ &NUpdateArchive::kAddActionSet, 0, 0, updateCallback100);
+ }
+ catch(const UString &s)
+ {
+ RINOK(updateCallback100->UpdateErrorMessage(UString(L"Error: ") + s));
+ return E_FAIL;
}
- return CommonUpdateOperation(false, false, false, NULL,
- &NUpdateArchive::kAddActionSet, 0, 0, updateCallback100);
COM_TRY_END
}
diff --git a/CPP/7zip/UI/Agent/IFolderArchive.h b/CPP/7zip/UI/Agent/IFolderArchive.h
index 7bb12482..91da1150 100755
--- a/CPP/7zip/UI/Agent/IFolderArchive.h
+++ b/CPP/7zip/UI/Agent/IFolderArchive.h
@@ -3,14 +3,13 @@
#ifndef __IFOLDER_ARCHIVE_H
#define __IFOLDER_ARCHIVE_H
+#include "../../IDecl.h"
#include "../../Archive/IArchive.h"
-// #include "../Format/Common/ArchiveInterface.h"
-#include "../../UI/FileManager/IFolder.h"
-#include "../Common/IFileExtractCallback.h"
-#include "../Common/ExtractMode.h"
#include "../../UI/Common/LoadCodecs.h"
+#include "../../UI/FileManager/IFolder.h"
-#include "../../IDecl.h"
+#include "../Common/ExtractMode.h"
+#include "../Common/IFileExtractCallback.h"
#define FOLDER_ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 0x01, x)
#define FOLDER_ARCHIVE_INTERFACE(i, x) FOLDER_ARCHIVE_INTERFACE_SUB(i, IUnknown, x)
@@ -28,7 +27,7 @@ FOLDER_ARCHIVE_INTERFACE(IArchiveFolder, 0x05)
};
#define INTERFACE_IInFolderArchive(x) \
- STDMETHOD(Open)(const wchar_t *filePath, BSTR *archiveType, IArchiveOpenCallback *openArchiveCallback) x; \
+ STDMETHOD(Open)(IInStream *inStream, const wchar_t *filePath, BSTR *archiveType, IArchiveOpenCallback *openArchiveCallback) x; \
STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback) x; \
STDMETHOD(Close)() x; \
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
@@ -38,7 +37,7 @@ FOLDER_ARCHIVE_INTERFACE(IArchiveFolder, 0x05)
NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, \
Int32 testMode, IFolderArchiveExtractCallback *extractCallback2) x; \
-FOLDER_ARCHIVE_INTERFACE(IInFolderArchive, 0x06)
+FOLDER_ARCHIVE_INTERFACE(IInFolderArchive, 0x0D)
{
INTERFACE_IInFolderArchive(PURE)
};
diff --git a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
index e14197d2..21549c90 100755
--- a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
+++ b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
@@ -90,19 +90,29 @@ HRESULT CUpdateCallbackAgent::SetOperationResult(Int32 operationResult)
HRESULT CUpdateCallbackAgent::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
{
+ *password = NULL;
*passwordIsDefined = BoolToInt(false);
if (!_cryptoGetTextPassword)
{
if (!Callback)
return S_OK;
- HRESULT result = Callback.QueryInterface(
- IID_ICryptoGetTextPassword2, &_cryptoGetTextPassword);
- if (result != S_OK)
+ Callback.QueryInterface(IID_ICryptoGetTextPassword2, &_cryptoGetTextPassword);
+ if (!_cryptoGetTextPassword)
return S_OK;
}
return _cryptoGetTextPassword->CryptoGetTextPassword2(passwordIsDefined, password);
}
+HRESULT CUpdateCallbackAgent::CryptoGetTextPassword(BSTR *password)
+{
+ *password = NULL;
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ Callback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
+ if (!getTextPassword)
+ return E_NOTIMPL;
+ return getTextPassword->CryptoGetTextPassword(password);
+}
+
/*
HRESULT CUpdateCallbackAgent::ShowDeleteFile(const wchar_t *name)
{