mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 02:07:07 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -8,11 +8,10 @@
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/FileFind.h"
|
||||
|
||||
#include "../Common/OpenArchive.h"
|
||||
#include "../Common/DefaultName.h"
|
||||
#include "../Common/ArchiveExtractCallback.h"
|
||||
|
||||
#include "Agent.h"
|
||||
#include "ArchiveExtractCallback.h"
|
||||
|
||||
#ifdef FORMAT_7Z
|
||||
#include "../../Archive/7z/7zHandler.h"
|
||||
@@ -62,8 +61,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARI
|
||||
break;
|
||||
default:
|
||||
if (item.IsLeaf)
|
||||
return _agentSpec->_archive->GetProperty(item.Index,
|
||||
propID, value);
|
||||
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -79,7 +77,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARI
|
||||
propVariant = item.Name;
|
||||
break;
|
||||
default:
|
||||
return _agentSpec->_archive->GetProperty(item.Index,
|
||||
return _agentSpec->GetArchive()->GetProperty(item.Index,
|
||||
propID, value);
|
||||
}
|
||||
}
|
||||
@@ -140,7 +138,7 @@ struct CArchiveItemPropertyTemp
|
||||
STDMETHODIMP CAgentFolder::GetNumberOfProperties(UINT32 *numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return _agentSpec->_archive->GetNumberOfProperties(numProperties);
|
||||
return _agentSpec->GetArchive()->GetNumberOfProperties(numProperties);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -148,7 +146,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
RINOK(_agentSpec->_archive->GetPropertyInfo(index, name, propID, varType));
|
||||
RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType));
|
||||
if (*propID == kpidPath)
|
||||
*propID = kpidName;
|
||||
return S_OK;
|
||||
@@ -200,8 +198,8 @@ STDMETHODIMP CAgentFolder::GetPath(BSTR *path)
|
||||
|
||||
STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
|
||||
UINT32 numItems,
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2)
|
||||
@@ -216,8 +214,9 @@ STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
|
||||
pathParts.Insert(0, currentProxyFolder->Name);
|
||||
currentProxyFolder = currentProxyFolder->Parent;
|
||||
}
|
||||
extractCallbackSpec->Init(_agentSpec->_archive,
|
||||
extractCallbackSpec->Init(_agentSpec->GetArchive(),
|
||||
extractCallback2,
|
||||
false,
|
||||
path,
|
||||
pathMode,
|
||||
overwriteMode,
|
||||
@@ -229,7 +228,7 @@ STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
|
||||
);
|
||||
CUIntVector realIndices;
|
||||
_proxyFolderItem->GetRealIndices(indices, numItems, realIndices);
|
||||
return _agentSpec->_archive->Extract(&realIndices.Front(),
|
||||
return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
|
||||
realIndices.Size(), testMode, extractCallback);
|
||||
COM_TRY_END
|
||||
}
|
||||
@@ -262,23 +261,19 @@ STDMETHODIMP CAgent::Open(
|
||||
return ::GetLastError();
|
||||
if (fileInfo.IsDirectory())
|
||||
return E_FAIL;
|
||||
CArchiverInfo archiverInfo;
|
||||
int subExtIndex;
|
||||
HRESULT res = OpenArchive(_archiveFilePath,
|
||||
#ifndef EXCLUDE_COM
|
||||
&_library,
|
||||
#endif
|
||||
&_archive, archiverInfo, subExtIndex, openArchiveCallback);
|
||||
CArchiverInfo archiverInfo0, archiverInfo1;
|
||||
HRESULT res = OpenArchive(_archiveFilePath, _archiveLink, openArchiveCallback);
|
||||
// _archive = _archiveLink.GetArchive();
|
||||
DefaultName = _archiveLink.GetDefaultItemName();
|
||||
const CArchiverInfo &ai = _archiveLink.GetArchiverInfo();
|
||||
|
||||
RINOK(res);
|
||||
DefaultName = GetDefaultName(_archiveFilePath,
|
||||
archiverInfo.Extensions[subExtIndex].Extension,
|
||||
archiverInfo.Extensions[subExtIndex].AddExtension);
|
||||
DefaultTime = fileInfo.LastWriteTime;
|
||||
DefaultAttributes = fileInfo.Attributes;
|
||||
ArchiveType = archiverInfo.Name;
|
||||
ArchiveType = ai.Name;
|
||||
if (archiveType != 0)
|
||||
{
|
||||
CMyComBSTR name = archiverInfo.Name;
|
||||
CMyComBSTR name = ArchiveType;
|
||||
*archiveType = name.Detach();
|
||||
}
|
||||
return S_OK;
|
||||
@@ -295,7 +290,7 @@ STDMETHODIMP CAgent::ReOpen(
|
||||
delete _proxyArchive;
|
||||
_proxyArchive = NULL;
|
||||
}
|
||||
RINOK(ReOpenArchive(_archive, _archiveFilePath));
|
||||
RINOK(ReOpenArchive(_archiveLink, _archiveFilePath));
|
||||
return ReadItems();
|
||||
COM_TRY_END
|
||||
}
|
||||
@@ -303,7 +298,13 @@ STDMETHODIMP CAgent::ReOpen(
|
||||
STDMETHODIMP CAgent::Close()
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return _archive->Close();
|
||||
RINOK(_archiveLink.Close());
|
||||
if (_archiveLink.GetNumLevels() > 1)
|
||||
{
|
||||
// return S_OK;
|
||||
}
|
||||
// _archive->Close();
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -319,7 +320,7 @@ HRESULT CAgent::ReadItems()
|
||||
if (_proxyArchive != NULL)
|
||||
return S_OK;
|
||||
_proxyArchive = new CProxyArchive();
|
||||
return _proxyArchive->Load(_archive,
|
||||
return _proxyArchive->Load(GetArchive(),
|
||||
DefaultName,
|
||||
// _defaultTime,
|
||||
// _defaultAttributes,
|
||||
@@ -340,8 +341,8 @@ STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
|
||||
|
||||
|
||||
STDMETHODIMP CAgent::Extract(
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2)
|
||||
@@ -349,8 +350,9 @@ STDMETHODIMP CAgent::Extract(
|
||||
COM_TRY_BEGIN
|
||||
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
|
||||
extractCallbackSpec->Init(_archive,
|
||||
extractCallbackSpec->Init(GetArchive(),
|
||||
extractCallback2,
|
||||
false,
|
||||
path,
|
||||
pathMode,
|
||||
overwriteMode,
|
||||
@@ -360,14 +362,14 @@ STDMETHODIMP CAgent::Extract(
|
||||
DefaultAttributes
|
||||
// ,_srcDirectoryPrefix
|
||||
);
|
||||
return _archive->Extract(0, -1, testMode, extractCallback);
|
||||
return GetArchive()->Extract(0, -1, testMode, extractCallback);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::GetNumberOfProperties(UINT32 *numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return _archive->GetNumberOfProperties(numProperties);
|
||||
return GetArchive()->GetNumberOfProperties(numProperties);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -375,7 +377,7 @@ STDMETHODIMP CAgent::GetPropertyInfo(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
RINOK(_archive->GetPropertyInfo(index, name, propID, varType));
|
||||
RINOK(GetArchive()->GetPropertyInfo(index, name, propID, varType));
|
||||
if (*propID == kpidPath)
|
||||
*propID = kpidName;
|
||||
return S_OK;
|
||||
@@ -385,14 +387,14 @@ STDMETHODIMP CAgent::GetPropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CAgent::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return _archive->GetArchiveProperty(propID, value);
|
||||
return GetArchive()->GetArchiveProperty(propID, value);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UINT32 *numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return _archive->GetNumberOfArchiveProperties(numProperties);
|
||||
return GetArchive()->GetNumberOfArchiveProperties(numProperties);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -400,7 +402,7 @@ STDMETHODIMP CAgent::GetArchivePropertyInfo(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return _archive->GetArchivePropertyInfo(index,
|
||||
return GetArchive()->GetArchivePropertyInfo(index,
|
||||
name, propID, varType);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Agent/Agent.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __AGENT_AGENT_H
|
||||
#define __AGENT_AGENT_H
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include <vector>
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/UpdateAction.h"
|
||||
#include "../Common/ArchiverInfo.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "IFolderArchive.h"
|
||||
#include "AgentProxy.h"
|
||||
@@ -74,8 +75,8 @@ public:
|
||||
|
||||
// IArchiveFolder
|
||||
STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback);
|
||||
@@ -137,6 +138,7 @@ public:
|
||||
CMyComPtr<IFolderFolder> _parentFolder;
|
||||
CMyComPtr<IInFolderArchive> _agent;
|
||||
CAgent *_agentSpec;
|
||||
private:
|
||||
};
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100030000}
|
||||
@@ -189,8 +191,8 @@ public:
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(BindToRootFolder)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(Extract)(
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2);
|
||||
@@ -204,11 +206,12 @@ public:
|
||||
const wchar_t *filePath,
|
||||
const CLSID *clsID,
|
||||
const wchar_t *newArchiveName,
|
||||
const BYTE *stateActions,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback);
|
||||
|
||||
HRESULT CommonUpdate(const wchar_t *newArchiveName,
|
||||
HRESULT CommonUpdate(
|
||||
const wchar_t *newArchiveName,
|
||||
int numUpdateItems,
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
|
||||
@@ -224,7 +227,7 @@ public:
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
|
||||
// ISetProperties
|
||||
STDMETHOD(SetProperties)(const BSTR *names, const PROPVARIANT *values, INT32 numProperties);
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, INT32 numProperties);
|
||||
#endif
|
||||
|
||||
CAgent();
|
||||
@@ -234,16 +237,14 @@ private:
|
||||
public:
|
||||
CProxyArchive *_proxyArchive;
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
NWindows::NDLL::CLibrary _library;
|
||||
#endif
|
||||
|
||||
CMyComPtr<IInArchive> _archive;
|
||||
CArchiveLink _archiveLink;
|
||||
// IInArchive *_archive2;
|
||||
|
||||
// CLSID _CLSID;
|
||||
// CMyComPtr<IArchiveFolder> m_RootFolder;
|
||||
|
||||
UString DefaultName;
|
||||
|
||||
FILETIME DefaultTime;
|
||||
UINT32 DefaultAttributes;
|
||||
|
||||
@@ -258,9 +259,12 @@ public:
|
||||
UString _archiveFilePath;
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
CObjectVector<CMyComBSTR> m_PropNames;
|
||||
CObjectVector<UString> m_PropNames;
|
||||
std::vector<NWindows::NCOM::CPropVariant> m_PropValues;
|
||||
#endif
|
||||
|
||||
IInArchive *GetArchive() { return _archiveLink.GetArchive(); }
|
||||
bool CanUpdate() const { return _archiveLink.GetNumLevels() <= 1; }
|
||||
};
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// Zip/Handler.cpp
|
||||
// AgentOutcpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../Common/UpdatePair.h"
|
||||
#include "../Common/EnumDirItems.h"
|
||||
#include "../Common/HandlerLoader.h"
|
||||
// #include "../Common/UpdatePairAction.h"
|
||||
// #include "../Common/CompressEngineCommon.h"
|
||||
// #include "../Common/UpdateProducer.h"
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/UpdatePair.h"
|
||||
#include "../Common/EnumDirItems.h"
|
||||
#include "../Common/HandlerLoader.h"
|
||||
#include "../Common/UpdateCallback.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "Agent.h"
|
||||
#include "ArchiveUpdateCallback.h"
|
||||
#include "UpdateCallbackAgent.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NCOM;
|
||||
@@ -90,7 +90,7 @@ STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
|
||||
static HRESULT GetFileTime(CAgent *agent, UINT32 itemIndex, FILETIME &fileTime)
|
||||
{
|
||||
CPropVariant property;
|
||||
RINOK(agent->_archive->GetProperty(itemIndex, kpidLastWriteTime, &property));
|
||||
RINOK(agent->GetArchive()->GetProperty(itemIndex, kpidLastWriteTime, &property));
|
||||
if (property.vt == VT_FILETIME)
|
||||
fileTime = property.filetime;
|
||||
else if (property.vt == VT_EMPTY)
|
||||
@@ -114,9 +114,9 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
|
||||
RINOK(::GetFileTime(agent, fileItem.Index, archiveItem.LastWriteTime));
|
||||
|
||||
CPropVariant property;
|
||||
agent->_archive->GetProperty(fileItem.Index, kpidSize, &property);
|
||||
agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property);
|
||||
if (archiveItem.SizeIsDefined = (property.vt != VT_EMPTY))
|
||||
archiveItem.Size = ConvertPropVariantToUINT64(property);
|
||||
archiveItem.Size = ConvertPropVariantToUInt64(property);
|
||||
archiveItem.IsDirectory = false;
|
||||
archiveItem.Name = prefix + fileItem.Name;
|
||||
archiveItem.Censored = true; // test it
|
||||
@@ -147,10 +147,12 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
const wchar_t *filePath,
|
||||
const CLSID *clsID,
|
||||
const wchar_t *newArchiveName,
|
||||
const BYTE *stateActions,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
NUpdateArchive::CActionSet actionSet;
|
||||
for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSet.StateActions[i] = (NUpdateArchive::NPairAction::EEnum)stateActions[i];
|
||||
@@ -159,18 +161,20 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
|
||||
UString folderPrefix = _folderPrefix;
|
||||
NFile::NName::NormalizeDirPathPrefix(folderPrefix);
|
||||
::EnumerateDirItems(folderPrefix, _names, _archiveNamePrefix, dirItems);
|
||||
RINOK(::EnumerateDirItems(folderPrefix, _names, _archiveNamePrefix, dirItems));
|
||||
|
||||
NWindows::NDLL::CLibrary library;
|
||||
|
||||
CMyComPtr<IOutArchive> outArchive;
|
||||
if (_archive)
|
||||
if (GetArchive())
|
||||
{
|
||||
RINOK(_archive.QueryInterface(IID_IOutArchive, &outArchive));
|
||||
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
|
||||
}
|
||||
else
|
||||
{
|
||||
CHandlerLoader loader;
|
||||
RINOK(loader.CreateHandler(filePath, *clsID, (void **)&outArchive, true));
|
||||
_library.Attach(loader.Detach());
|
||||
library.Attach(loader.Detach());
|
||||
}
|
||||
|
||||
NFileTimeType::EEnum fileTimeType;
|
||||
@@ -191,7 +195,7 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
CObjectVector<CUpdatePair> updatePairs;
|
||||
|
||||
CObjectVector<CArchiveItem> archiveItems;
|
||||
if (_archive)
|
||||
if (GetArchive())
|
||||
{
|
||||
RINOK(ReadItems());
|
||||
EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", archiveItems);
|
||||
@@ -199,16 +203,22 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
|
||||
GetUpdatePairInfoList(dirItems, archiveItems, fileTimeType, updatePairs);
|
||||
|
||||
CObjectVector<CUpdatePair2> operationChain;
|
||||
CObjectVector<CUpdatePair2> updatePairs2;
|
||||
UpdateProduce(dirItems, archiveItems, updatePairs, actionSet,
|
||||
operationChain);
|
||||
updatePairs2);
|
||||
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(folderPrefix,&dirItems, &archiveItems,
|
||||
&operationChain, NULL, updateCallback100);
|
||||
|
||||
|
||||
updateCallbackSpec->DirPrefix = folderPrefix;
|
||||
updateCallbackSpec->DirItems = &dirItems;
|
||||
updateCallbackSpec->ArchiveItems = &archiveItems;
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs2;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
|
||||
COutFileStream *outStreamSpec = new COutFileStream;
|
||||
CMyComPtr<IOutStream> outStream(outStreamSpec);
|
||||
UString archiveName = newArchiveName;
|
||||
@@ -219,7 +229,7 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
throw 141716;
|
||||
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
|
||||
}
|
||||
if (!outStreamSpec->Open(archiveName))
|
||||
if (!outStreamSpec->Create(archiveName, true))
|
||||
{
|
||||
// ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
@@ -234,11 +244,12 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<BSTR> names;
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(i = 0; i < m_PropNames.Size(); i++)
|
||||
names.push_back(m_PropNames[i]);
|
||||
RINOK(setProperties->SetProperties(&names.front(),
|
||||
&m_PropValues.front(), names.size()));
|
||||
names.Add((const wchar_t *)m_PropNames[i]);
|
||||
|
||||
RINOK(setProperties->SetProperties(&names.Front(),
|
||||
&m_PropValues.front(), names.Size()));
|
||||
}
|
||||
}
|
||||
m_PropNames.Clear();
|
||||
@@ -253,20 +264,24 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
RINOK(CopyBlock(sfxStream, outStream));
|
||||
}
|
||||
|
||||
return outArchive->UpdateItems(outStream, operationChain.Size(),
|
||||
return outArchive->UpdateItems(outStream, updatePairs2.Size(),
|
||||
updateCallback);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CAgent::CommonUpdate(const wchar_t *newArchiveName,
|
||||
HRESULT CAgent::CommonUpdate(
|
||||
const wchar_t *newArchiveName,
|
||||
int numUpdateItems,
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CMyComPtr<IOutArchive> outArchive;
|
||||
RINOK(_archive.QueryInterface(IID_IOutArchive, &outArchive));
|
||||
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
|
||||
|
||||
COutFileStream *outStreamSpec = new COutFileStream;
|
||||
CMyComPtr<IOutStream> outStream(outStreamSpec);
|
||||
|
||||
UString archiveName = newArchiveName;
|
||||
{
|
||||
UString resultPath;
|
||||
@@ -275,7 +290,30 @@ HRESULT CAgent::CommonUpdate(const wchar_t *newArchiveName,
|
||||
throw 141716;
|
||||
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
|
||||
}
|
||||
if (!outStreamSpec->Open(archiveName))
|
||||
|
||||
/*
|
||||
bool isOK = false;
|
||||
for (int i = 0; i < (1 << 16); i++)
|
||||
{
|
||||
resultName = newArchiveName;
|
||||
if (i > 0)
|
||||
{
|
||||
wchar_t s[32];
|
||||
ConvertUInt64ToString(i, s);
|
||||
resultName += s;
|
||||
}
|
||||
if (outStreamSpec->Open(realPath))
|
||||
{
|
||||
isOK = true;
|
||||
break;
|
||||
}
|
||||
if (::GetLastError() != ERROR_FILE_EXISTS)
|
||||
return ::GetLastError();
|
||||
}
|
||||
if (!isOK)
|
||||
return ::GetLastError();
|
||||
*/
|
||||
if (!outStreamSpec->Create(archiveName, true))
|
||||
{
|
||||
// ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
@@ -290,6 +328,10 @@ STDMETHODIMP CAgent::DeleteItems(
|
||||
const UINT32 *indices, UINT32 numItems,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
@@ -298,7 +340,7 @@ STDMETHODIMP CAgent::DeleteItems(
|
||||
CObjectVector<CUpdatePair2> updatePairs;
|
||||
int curIndex = 0;
|
||||
UINT32 numItemsInArchive;
|
||||
RINOK(_archive->GetNumberOfItems(&numItemsInArchive));
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (int i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
if (curIndex < realIndices.Size())
|
||||
@@ -311,11 +353,13 @@ STDMETHODIMP CAgent::DeleteItems(
|
||||
updatePair.NewData = updatePair.NewProperties = false;
|
||||
updatePair.ExistInArchive = true;
|
||||
updatePair.ExistOnDisk = false;
|
||||
updatePair.IsAnti = false;
|
||||
updatePair.IsAnti = false; // check it. Maybe it can be undefined
|
||||
updatePair.ArchiveItemIndex = i;
|
||||
updatePairs.Add(updatePair);
|
||||
}
|
||||
updateCallbackSpec->Init(L"", NULL, NULL, &updatePairs, NULL, updateCallback100);
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
@@ -324,19 +368,23 @@ HRESULT CAgent::CreateFolder(
|
||||
const wchar_t *folderName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
CObjectVector<CUpdatePair2> updatePairs;
|
||||
UINT32 numItemsInArchive;
|
||||
RINOK(_archive->GetNumberOfItems(&numItemsInArchive));
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (int i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
CUpdatePair2 updatePair;
|
||||
updatePair.NewData = updatePair.NewProperties = false;
|
||||
updatePair.ExistInArchive = true;
|
||||
updatePair.ExistOnDisk = false;
|
||||
updatePair.IsAnti = false;
|
||||
updatePair.IsAnti = false; // check it.
|
||||
updatePair.ArchiveItemIndex = i;
|
||||
updatePairs.Add(updatePair);
|
||||
}
|
||||
@@ -366,7 +414,10 @@ HRESULT CAgent::CreateFolder(
|
||||
|
||||
dirItems.Add(dirItem);
|
||||
|
||||
updateCallbackSpec->Init(L"", &dirItems, NULL, &updatePairs, NULL, updateCallback100);
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
updateCallbackSpec->DirItems = &dirItems;
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
@@ -377,8 +428,12 @@ HRESULT CAgent::RenameItem(
|
||||
const wchar_t *newItemName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
if (numItems != 1)
|
||||
return E_INVALIDARG;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
@@ -393,7 +448,7 @@ HRESULT CAgent::RenameItem(
|
||||
CObjectVector<CUpdatePair2> updatePairs;
|
||||
int curIndex = 0;
|
||||
UINT32 numItemsInArchive;
|
||||
RINOK(_archive->GetNumberOfItems(&numItemsInArchive));
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (int i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
if (curIndex < realIndices.Size())
|
||||
@@ -404,37 +459,19 @@ HRESULT CAgent::RenameItem(
|
||||
updatePair.NewProperties = true;
|
||||
updatePair.ExistInArchive = true;
|
||||
updatePair.ExistOnDisk = false;
|
||||
updatePair.IsAnti = false; // ?
|
||||
RINOK(IsArchiveItemAnti(GetArchive(), i, updatePair.IsAnti));
|
||||
updatePair.ArchiveItemIndex = i;
|
||||
updatePair.NewNameIsDefined = true;
|
||||
|
||||
updatePair.NewName = newItemName;
|
||||
|
||||
UString oldFullPath;
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(_archive->GetProperty(
|
||||
updatePair.ArchiveItemIndex, kpidPath, &propVariant));
|
||||
if (propVariant.vt != VT_BSTR)
|
||||
return E_INVALIDARG;
|
||||
oldFullPath = propVariant.bstrVal;
|
||||
}
|
||||
RINOK(GetArchiveItemPath(GetArchive(), i, DefaultName, oldFullPath));
|
||||
|
||||
if (oldItemPath.CollateNoCase(oldFullPath.Left(oldItemPath.Length())) != 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(_archive->GetProperty(i, kpidIsAnti, &propVariant));
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
updatePair.IsAnti = false;
|
||||
else if (propVariant.vt != VT_BOOL)
|
||||
return E_INVALIDARG;
|
||||
else
|
||||
updatePair.IsAnti = (propVariant.boolVal != VARIANT_FALSE);
|
||||
}
|
||||
|
||||
updatePair.NewName = newItemPath + oldFullPath.Mid(oldItemPath.Length());
|
||||
|
||||
updatePairs.Add(updatePair);
|
||||
curIndex++;
|
||||
continue;
|
||||
@@ -447,13 +484,13 @@ HRESULT CAgent::RenameItem(
|
||||
updatePair.ArchiveItemIndex = i;
|
||||
updatePairs.Add(updatePair);
|
||||
}
|
||||
updateCallbackSpec->Init(L"", NULL, NULL, &updatePairs, _archive, updateCallback100);
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
STDMETHODIMP CAgent::SetProperties(const BSTR *names,
|
||||
STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
|
||||
const PROPVARIANT *values, INT32 numProperties)
|
||||
{
|
||||
m_PropNames.Clear();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -184,11 +185,9 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archiveHandler, IProgress *progre
|
||||
}
|
||||
|
||||
NCOM::CPropVariant propVariantIsFolder;
|
||||
RINOK(archiveHandler->GetProperty(i,
|
||||
kpidIsFolder, &propVariantIsFolder));
|
||||
if(propVariantIsFolder.vt != VT_BOOL)
|
||||
return E_FAIL;
|
||||
if(VARIANT_BOOLToBool(propVariantIsFolder.boolVal))
|
||||
bool isFolder;
|
||||
RINOK(IsArchiveItemFolder(archiveHandler, i, isFolder));
|
||||
if(isFolder)
|
||||
currentItem->AddDirSubItem(i, true, fileName);
|
||||
else
|
||||
currentItem->AddFileSubItem(i, fileName);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// AgentProxy.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __AGENT_PROXY_H
|
||||
#define __AGENT_PROXY_H
|
||||
|
||||
|
||||
@@ -1,358 +0,0 @@
|
||||
// ExtractCallback.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ArchiveExtractCallback.h"
|
||||
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/Time.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
#include "../Common/ExtractingFilePath.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
void CArchiveExtractCallback::Init(
|
||||
IInArchive *archiveHandler,
|
||||
IFolderArchiveExtractCallback *extractCallback2,
|
||||
const UString &directoryPath,
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
const UStringVector &removePathParts,
|
||||
const UString &itemDefaultName,
|
||||
const FILETIME &utcLastWriteTimeDefault,
|
||||
UINT32 attributesDefault)
|
||||
// bool passwordIsDefined, const UString &password
|
||||
// UString srcDirectoryPrefix)
|
||||
{
|
||||
_extractCallback2 = extractCallback2;
|
||||
// m_PasswordIsDefined = passwordIsDefined;
|
||||
// m_Password = password;
|
||||
_numErrors = 0;
|
||||
|
||||
_itemDefaultName = itemDefaultName;
|
||||
_utcLastWriteTimeDefault = utcLastWriteTimeDefault;
|
||||
_attributesDefault = attributesDefault;
|
||||
|
||||
_removePathParts = removePathParts;
|
||||
|
||||
_pathMode = pathMode;
|
||||
_overwriteMode = overwriteMode;
|
||||
|
||||
_archiveHandler = archiveHandler;
|
||||
_directoryPath = directoryPath;
|
||||
NFile::NName::NormalizeDirPathPrefix(_directoryPath);
|
||||
|
||||
// _srcDirectoryPrefix = srcDirectoryPrefix;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::SetTotal(UINT64 size)
|
||||
{
|
||||
return _extractCallback2->SetTotal(size);
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UINT64 *completeValue)
|
||||
{
|
||||
return _extractCallback2->SetCompleted(completeValue);
|
||||
}
|
||||
|
||||
void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts)
|
||||
{
|
||||
UString fullPath = _directoryPath;
|
||||
for(int i = 0; i < dirPathParts.Size(); i++)
|
||||
{
|
||||
fullPath += dirPathParts[i];
|
||||
NFile::NDirectory::MyCreateDirectory(fullPath);
|
||||
fullPath += wchar_t(NFile::NName::kDirDelimiter);
|
||||
}
|
||||
}
|
||||
|
||||
static UString MakePathNameFromParts(const UStringVector &parts)
|
||||
{
|
||||
UString result;
|
||||
for(int i = 0; i < parts.Size(); i++)
|
||||
{
|
||||
if(i != 0)
|
||||
result += wchar_t(NFile::NName::kDirDelimiter);
|
||||
result += parts[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::GetStream(UINT32 index,
|
||||
ISequentialOutStream **outStream, INT32 askExtractMode)
|
||||
{
|
||||
*outStream = 0;
|
||||
_outFileStream.Release();
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidPath, &propVariant));
|
||||
|
||||
UString fullPath;
|
||||
if(propVariant.vt == VT_EMPTY)
|
||||
{
|
||||
fullPath = _itemDefaultName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(propVariant.vt != VT_BSTR)
|
||||
return E_FAIL;
|
||||
fullPath = propVariant.bstrVal;
|
||||
}
|
||||
|
||||
// UString fullPathCorrect = GetCorrectPath(fullPath);
|
||||
_filePath = fullPath;
|
||||
|
||||
if(askExtractMode == NArchive::NExtract::NAskMode::kExtract)
|
||||
{
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidAttributes, &propVariant));
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
{
|
||||
_processedFileInfo.Attributes = _attributesDefault;
|
||||
_processedFileInfo.AttributesAreDefined = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (propVariant.vt != VT_UI4)
|
||||
throw "incorrect item";
|
||||
_processedFileInfo.Attributes = propVariant.ulVal;
|
||||
_processedFileInfo.AttributesAreDefined = true;
|
||||
}
|
||||
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidIsFolder, &propVariant));
|
||||
_processedFileInfo.IsDirectory = VARIANT_BOOLToBool(propVariant.boolVal);
|
||||
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidLastWriteTime, &propVariant));
|
||||
switch(propVariant.vt)
|
||||
{
|
||||
case VT_EMPTY:
|
||||
_processedFileInfo.UTCLastWriteTime = _utcLastWriteTimeDefault;
|
||||
break;
|
||||
case VT_FILETIME:
|
||||
_processedFileInfo.UTCLastWriteTime = propVariant.filetime;
|
||||
break;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidSize, &propVariant));
|
||||
bool newFileSizeDefined = (propVariant.vt != VT_EMPTY);
|
||||
UINT64 newFileSize;
|
||||
if (newFileSizeDefined)
|
||||
newFileSize = ConvertPropVariantToUINT64(propVariant);
|
||||
|
||||
bool isAnti = false;
|
||||
{
|
||||
NCOM::CPropVariant propVariantTemp;
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidIsAnti,
|
||||
&propVariantTemp));
|
||||
if (propVariantTemp.vt == VT_BOOL)
|
||||
isAnti = VARIANT_BOOLToBool(propVariantTemp.boolVal);
|
||||
}
|
||||
|
||||
UStringVector pathParts;
|
||||
|
||||
// SplitPathToParts(fullPathCorrect, pathParts);
|
||||
SplitPathToParts(fullPath, pathParts);
|
||||
|
||||
if(pathParts.IsEmpty())
|
||||
return E_FAIL;
|
||||
UString processedPath;
|
||||
switch(_pathMode)
|
||||
{
|
||||
case NExtractionMode::NPath::kFullPathnames:
|
||||
{
|
||||
// processedPath = fullPathCorrect;
|
||||
processedPath = GetCorrectPath(fullPath);
|
||||
break;
|
||||
}
|
||||
case NExtractionMode::NPath::kCurrentPathnames:
|
||||
{
|
||||
int numRemovePathParts = _removePathParts.Size();
|
||||
if(pathParts.Size() <= numRemovePathParts)
|
||||
return E_FAIL;
|
||||
for(int i = 0; i < numRemovePathParts; i++)
|
||||
if(_removePathParts[i].CollateNoCase(pathParts[i]) != 0)
|
||||
return E_FAIL;
|
||||
pathParts.Delete(0, numRemovePathParts);
|
||||
processedPath = MakePathNameFromParts(pathParts);
|
||||
processedPath = GetCorrectPath(processedPath);
|
||||
break;
|
||||
}
|
||||
case NExtractionMode::NPath::kNoPathnames:
|
||||
{
|
||||
processedPath = pathParts.Back();
|
||||
pathParts.Delete(0, pathParts.Size() - 1); // Test it!!
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!_processedFileInfo.IsDirectory)
|
||||
pathParts.DeleteBack();
|
||||
|
||||
for(int i = 0; i < pathParts.Size(); i++)
|
||||
pathParts[i] = GetCorrectFileName(pathParts[i]);
|
||||
|
||||
if (!isAnti)
|
||||
if (!pathParts.IsEmpty())
|
||||
CreateComplexDirectory(pathParts);
|
||||
|
||||
|
||||
const UString fullProcessedPathUnicode = _directoryPath + processedPath;
|
||||
UString fullProcessedPath = _directoryPath + processedPath;
|
||||
|
||||
if(_processedFileInfo.IsDirectory)
|
||||
{
|
||||
_diskFilePath = fullProcessedPath;
|
||||
if (isAnti)
|
||||
NFile::NDirectory::MyRemoveDirectory(_diskFilePath);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if(NFile::NFind::FindFile(fullProcessedPath, fileInfo))
|
||||
{
|
||||
switch(_overwriteMode)
|
||||
{
|
||||
case NExtractionMode::NOverwrite::kSkipExisting:
|
||||
return S_OK;
|
||||
case NExtractionMode::NOverwrite::kAskBefore:
|
||||
{
|
||||
INT32 overwiteResult;
|
||||
RINOK(_extractCallback2->AskOverwrite(
|
||||
fullProcessedPathUnicode, &fileInfo.LastWriteTime, &fileInfo.Size,
|
||||
fullPath, &_processedFileInfo.UTCLastWriteTime, newFileSizeDefined?
|
||||
&newFileSize : NULL, &overwiteResult))
|
||||
|
||||
switch(overwiteResult)
|
||||
{
|
||||
case NOverwriteAnswer::kCancel:
|
||||
return E_ABORT;
|
||||
case NOverwriteAnswer::kNo:
|
||||
return S_OK;
|
||||
case NOverwriteAnswer::kNoToAll:
|
||||
_overwriteMode = NExtractionMode::NOverwrite::kSkipExisting;
|
||||
return S_OK;
|
||||
case NOverwriteAnswer::kYesToAll:
|
||||
_overwriteMode = NExtractionMode::NOverwrite::kWithoutPrompt;
|
||||
break;
|
||||
case NOverwriteAnswer::kYes:
|
||||
break;
|
||||
case NOverwriteAnswer::kAutoRename:
|
||||
_overwriteMode = NExtractionMode::NOverwrite::kAutoRename;
|
||||
break;
|
||||
default:
|
||||
throw 20413;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_overwriteMode == NExtractionMode::NOverwrite::kAutoRename)
|
||||
{
|
||||
if (!AutoRenamePath(fullProcessedPath))
|
||||
{
|
||||
UString message = UString(L"can not create name of file ") +
|
||||
fullProcessedPathUnicode;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
|
||||
{
|
||||
UString message = UString(L"can not delete output file ") +
|
||||
fullProcessedPathUnicode;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
if (!isAnti)
|
||||
{
|
||||
_outFileStreamSpec = new COutFileStream;
|
||||
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
|
||||
if (!_outFileStreamSpec->Open(fullProcessedPath))
|
||||
{
|
||||
UString message = L"can not open output file " + fullProcessedPathUnicode;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
return S_OK;
|
||||
}
|
||||
_outFileStream = outStreamLoc;
|
||||
*outStream = outStreamLoc.Detach();
|
||||
}
|
||||
_diskFilePath = fullProcessedPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
*outStream = NULL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::PrepareOperation(INT32 askExtractMode)
|
||||
{
|
||||
_extractMode = false;
|
||||
switch (askExtractMode)
|
||||
{
|
||||
case NArchive::NExtract::NAskMode::kExtract:
|
||||
_extractMode = true;
|
||||
};
|
||||
return _extractCallback2->PrepareOperation(_filePath, askExtractMode);
|
||||
}
|
||||
|
||||
void CArchiveExtractCallback::AddErrorMessage(LPCTSTR message)
|
||||
{
|
||||
_messages.Add(message);
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::SetOperationResult(INT32 operationResult)
|
||||
{
|
||||
switch(operationResult)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kOK:
|
||||
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
|
||||
case NArchive::NExtract::NOperationResult::kCRCError:
|
||||
case NArchive::NExtract::NOperationResult::kDataError:
|
||||
break;
|
||||
default:
|
||||
_outFileStream.Release();
|
||||
return E_FAIL;
|
||||
}
|
||||
if(_outFileStream != NULL)
|
||||
_outFileStreamSpec->File.SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
|
||||
_outFileStream.Release();
|
||||
if (_extractMode && _processedFileInfo.AttributesAreDefined)
|
||||
NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
|
||||
RINOK(_extractCallback2->SetOperationResult(operationResult));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CArchiveExtractCallback::GetInStream(
|
||||
const wchar_t *name, ISequentialInStream **inStream)
|
||||
{
|
||||
CInFileStream *inFile = new CInFileStream;
|
||||
CMyComPtr<ISequentialInStream> inStreamTemp = inFile;
|
||||
if (!inFile->Open(_srcDirectoryPrefix + name))
|
||||
return ::GetLastError();
|
||||
*inStream = inStreamTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
if (!_cryptoGetTextPassword)
|
||||
{
|
||||
RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword,
|
||||
&_cryptoGetTextPassword));
|
||||
}
|
||||
return _cryptoGetTextPassword->CryptoGetTextPassword(password);
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
// ArchiveExtractCallback.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __ARCHIVEEXTRACTCALLBACK_H
|
||||
#define __ARCHIVEEXTRACTCALLBACK_H
|
||||
|
||||
#include "../../Archive/IArchive.h"
|
||||
#include "IFolderArchive.h"
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
#include "../../IPassword.h"
|
||||
|
||||
class CArchiveExtractCallback:
|
||||
public IArchiveExtractCallback,
|
||||
// public IArchiveVolumeExtractCallback,
|
||||
public ICryptoGetTextPassword,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
|
||||
// COM_INTERFACE_ENTRY(IArchiveVolumeExtractCallback)
|
||||
|
||||
// IProgress
|
||||
STDMETHOD(SetTotal)(UINT64 aize);
|
||||
STDMETHOD(SetCompleted)(const UINT64 *completeValue);
|
||||
|
||||
// IExtractCallBack
|
||||
STDMETHOD(GetStream)(UINT32 anIndex, ISequentialOutStream **outStream,
|
||||
INT32 askExtractMode);
|
||||
STDMETHOD(PrepareOperation)(INT32 askExtractMode);
|
||||
STDMETHOD(SetOperationResult)(INT32 resultEOperationResult);
|
||||
|
||||
// IArchiveVolumeExtractCallback
|
||||
// STDMETHOD(GetInStream)(const wchar_t *name, ISequentialInStream **inStream);
|
||||
|
||||
// ICryptoGetTextPassword
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *aPassword);
|
||||
|
||||
private:
|
||||
CMyComPtr<IInArchive> _archiveHandler;
|
||||
CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2;
|
||||
CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword;
|
||||
UString _directoryPath;
|
||||
NExtractionMode::NPath::EEnum _pathMode;
|
||||
NExtractionMode::NOverwrite::EEnum _overwriteMode;
|
||||
|
||||
UString _filePath;
|
||||
|
||||
UString _diskFilePath;
|
||||
|
||||
CSysStringVector _messages;
|
||||
|
||||
bool _extractMode;
|
||||
struct CProcessedFileInfo
|
||||
{
|
||||
FILETIME UTCLastWriteTime;
|
||||
bool IsDirectory;
|
||||
bool AttributesAreDefined;
|
||||
UINT32 Attributes;
|
||||
} _processedFileInfo;
|
||||
|
||||
|
||||
COutFileStream *_outFileStreamSpec;
|
||||
CMyComPtr<ISequentialOutStream> _outFileStream;
|
||||
UStringVector _removePathParts;
|
||||
|
||||
UString _itemDefaultName;
|
||||
FILETIME _utcLastWriteTimeDefault;
|
||||
UINT32 _attributesDefault;
|
||||
|
||||
// bool m_PasswordIsDefined;
|
||||
// UString m_Password;
|
||||
|
||||
|
||||
// UString _srcDirectoryPrefix;
|
||||
|
||||
void CreateComplexDirectory(const UStringVector &dirPathParts);
|
||||
/*
|
||||
void GetPropertyValue(LPITEMIDLIST anItemIDList, PROPID aPropId,
|
||||
PROPVARIANT *aValue);
|
||||
bool IsEncrypted(LPITEMIDLIST anItemIDList);
|
||||
*/
|
||||
void AddErrorMessage(LPCTSTR message);
|
||||
public:
|
||||
// CProgressDialog m_ProcessDialog;
|
||||
void Init(
|
||||
IInArchive *archiveHandler,
|
||||
IFolderArchiveExtractCallback *extractCallback2,
|
||||
const UString &directoryPath,
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
const UStringVector &removePathParts,
|
||||
const UString &itemDefaultName,
|
||||
const FILETIME &utcLastWriteTimeDefault,
|
||||
UINT32 anAttributesDefault
|
||||
// bool passwordIsDefined, const UString &password
|
||||
// UString srcDirectoryPrefix
|
||||
);
|
||||
|
||||
UINT64 _numErrors;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -12,9 +12,9 @@
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/UpdatePair.h"
|
||||
#include "../Common/ArchiveExtractCallback.h"
|
||||
|
||||
#include "Agent.h"
|
||||
#include "ArchiveExtractCallback.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NCOM;
|
||||
@@ -41,11 +41,12 @@ STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
|
||||
IID_IFolderArchiveExtractCallback, &extractCallback2));
|
||||
}
|
||||
|
||||
extractCallbackSpec->Init(_agentSpec->_archive,
|
||||
extractCallbackSpec->Init(_agentSpec->GetArchive(),
|
||||
extractCallback2,
|
||||
false,
|
||||
path,
|
||||
NExtractionMode::NPath::kCurrentPathnames,
|
||||
NExtractionMode::NOverwrite::kAskBefore,
|
||||
NExtract::NPathMode::kCurrentPathnames,
|
||||
NExtract::NOverwriteMode::kAskBefore,
|
||||
pathParts,
|
||||
_agentSpec->DefaultName,
|
||||
_agentSpec->DefaultTime,
|
||||
@@ -54,7 +55,7 @@ STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
|
||||
);
|
||||
CUIntVector realIndices;
|
||||
_proxyFolderItem->GetRealIndices(indices, numItems, realIndices);
|
||||
return _agentSpec->_archive->Extract(&realIndices.Front(),
|
||||
return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
|
||||
realIndices.Size(), BoolToInt(false), extractCallback);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
static const UINT64 kMaxCheckStartPosition = 1 << 20;
|
||||
static const UInt64 kMaxCheckStartPosition = 1 << 20;
|
||||
|
||||
static inline UINT GetCurrentFileCodePage()
|
||||
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
|
||||
@@ -85,7 +85,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = actionSet->StateActions[i];
|
||||
result = _agentSpec->DoOperation(NULL, NULL,
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
// ArchiveUpdateCallback.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ArchiveUpdateCallback.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Defs.h"
|
||||
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
void CArchiveUpdateCallback::Init(const UString &baseFolderPrefix,
|
||||
const CObjectVector<CDirItem> *dirItems,
|
||||
const CObjectVector<CArchiveItem> *archiveItems, // test CItemInfoExList
|
||||
CObjectVector<CUpdatePair2> *updatePairs,
|
||||
IInArchive *inArchive,
|
||||
IFolderArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
m_BaseFolderPrefix = baseFolderPrefix;
|
||||
NFile::NName::NormalizeDirPathPrefix(m_BaseFolderPrefix);
|
||||
m_DirItems = dirItems;
|
||||
m_ArchiveItems = archiveItems;
|
||||
m_UpdatePairs = updatePairs;
|
||||
m_UpdateCallback = updateCallback;
|
||||
m_CodePage = ::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
_inArchive = inArchive;;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::SetTotal(UINT64 size)
|
||||
{
|
||||
if (m_UpdateCallback)
|
||||
return m_UpdateCallback->SetTotal(size);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UINT64 *completeValue)
|
||||
{
|
||||
if (m_UpdateCallback)
|
||||
return m_UpdateCallback->SetCompleted(completeValue);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsFolder, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidLastAccessTime, VT_FILETIME},
|
||||
{ NULL, kpidCreationTime, VT_FILETIME},
|
||||
{ NULL, kpidLastWriteTime, VT_FILETIME},
|
||||
{ NULL, kpidAttributes, VT_UI4},
|
||||
{ NULL, kpidIsAnti, VT_BOOL}
|
||||
};
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG **enumerator)
|
||||
{
|
||||
return CStatPropEnumerator::CreateEnumerator(kProperties,
|
||||
sizeof(kProperties) / sizeof(kProperties[0]), enumerator);
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UINT32 index,
|
||||
INT32 *newData, INT32 *newProperties, UINT32 *indexInArchive)
|
||||
{
|
||||
const CUpdatePair2 &updatePair = (*m_UpdatePairs)[index];
|
||||
if(newData != NULL)
|
||||
*newData = BoolToInt(updatePair.NewData);
|
||||
if(newProperties != NULL)
|
||||
*newProperties = BoolToInt(updatePair.NewProperties);
|
||||
if(indexInArchive != NULL)
|
||||
{
|
||||
if (updatePair.ExistInArchive)
|
||||
{
|
||||
if (m_ArchiveItems == 0)
|
||||
*indexInArchive = updatePair.ArchiveItemIndex;
|
||||
else
|
||||
*indexInArchive = (*m_ArchiveItems)[updatePair.ArchiveItemIndex].IndexInServer;
|
||||
}
|
||||
else
|
||||
*indexInArchive = UINT32(-1);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
const CUpdatePair2 &updatePair = (*m_UpdatePairs)[index];
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
|
||||
if (propID == kpidIsAnti)
|
||||
{
|
||||
propVariant = updatePair.IsAnti;
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (updatePair.IsAnti)
|
||||
{
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsFolder:
|
||||
case kpidPath:
|
||||
break;
|
||||
case kpidSize:
|
||||
propVariant = (UINT64)0;
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
default:
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if(updatePair.ExistOnDisk)
|
||||
{
|
||||
const CDirItem &dirItem = (*m_DirItems)[updatePair.DirItemIndex];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
propVariant = dirItem.Name;
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
propVariant = dirItem.IsDirectory();
|
||||
break;
|
||||
case kpidSize:
|
||||
propVariant = dirItem.Size;
|
||||
break;
|
||||
case kpidAttributes:
|
||||
propVariant = dirItem.Attributes;
|
||||
break;
|
||||
case kpidLastAccessTime:
|
||||
propVariant = dirItem.LastAccessTime;
|
||||
break;
|
||||
case kpidCreationTime:
|
||||
propVariant = dirItem.CreationTime;
|
||||
break;
|
||||
case kpidLastWriteTime:
|
||||
propVariant = dirItem.LastWriteTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (propID == kpidPath)
|
||||
{
|
||||
if (updatePair.NewNameIsDefined)
|
||||
{
|
||||
propVariant = updatePair.NewName;
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
if (updatePair.ExistInArchive && _inArchive)
|
||||
{
|
||||
UINT32 indexInArchive;
|
||||
if (m_ArchiveItems == 0)
|
||||
indexInArchive = updatePair.ArchiveItemIndex;
|
||||
else
|
||||
indexInArchive = (*m_ArchiveItems)[updatePair.ArchiveItemIndex].IndexInServer;
|
||||
return _inArchive->GetProperty(indexInArchive, propID, value);
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetStream(UINT32 index,
|
||||
IInStream **inStream)
|
||||
{
|
||||
const CUpdatePair2 &updatePair = (*m_UpdatePairs)[index];
|
||||
if(!updatePair.NewData)
|
||||
return E_FAIL;
|
||||
const CDirItem &dirItem = (*m_DirItems)[updatePair.DirItemIndex];
|
||||
|
||||
/*
|
||||
m_PercentPrinter.PrintString("Compressing ");
|
||||
m_PercentCanBePrint = true;
|
||||
m_PercentPrinter.PrintString(UnicodeStringToMultiByte(dirItem.Name, CP_OEMCP));
|
||||
m_PercentPrinter.PreparePrint();
|
||||
m_PercentPrinter.RePrintRatio();
|
||||
*/
|
||||
|
||||
if (m_UpdateCallback)
|
||||
{
|
||||
RINOK(m_UpdateCallback->CompressOperation(
|
||||
GetUnicodeString(dirItem.FullPath, m_CodePage)));
|
||||
}
|
||||
|
||||
if(dirItem.IsDirectory())
|
||||
return S_OK;
|
||||
|
||||
CInFileStream *inStreamSpec = new CInFileStream;
|
||||
CMyComPtr<IInStream> inStreamLoc(inStreamSpec);
|
||||
if(!inStreamSpec->Open(m_BaseFolderPrefix + dirItem.FullPath))
|
||||
return ::GetLastError();
|
||||
|
||||
*inStream = inStreamLoc.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::SetOperationResult(INT32 operationResult)
|
||||
{
|
||||
if (m_UpdateCallback)
|
||||
return m_UpdateCallback->OperationResult(operationResult);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(INT32 *passwordIsDefined, BSTR *password)
|
||||
{
|
||||
*passwordIsDefined = BoolToInt(false);
|
||||
if (!_cryptoGetTextPassword)
|
||||
{
|
||||
if (!m_UpdateCallback)
|
||||
return S_OK;
|
||||
HRESULT result = m_UpdateCallback.QueryInterface(
|
||||
IID_ICryptoGetTextPassword2, &_cryptoGetTextPassword);
|
||||
if (result != S_OK)
|
||||
return S_OK;
|
||||
}
|
||||
return _cryptoGetTextPassword->CryptoGetTextPassword2(passwordIsDefined, password);
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
// ArchiveUpdateCallback.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __ARCHIVEUPDATECALLBACK_H
|
||||
#define __ARCHIVEUPDATECALLBACK_H
|
||||
|
||||
#include "../../Archive/IArchive.h"
|
||||
#include "../../IPassword.h"
|
||||
#include "IFolderArchive.h"
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../Common/UpdateProduce.h"
|
||||
// #include "Interface/CryptoInterface.h"
|
||||
// #include "Interface/MyCom.h"
|
||||
|
||||
class CArchiveUpdateCallback:
|
||||
public IArchiveUpdateCallback,
|
||||
public ICryptoGetTextPassword2,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(ICryptoGetTextPassword2)
|
||||
|
||||
|
||||
// IProgress
|
||||
|
||||
STDMETHOD(SetTotal)(UINT64 size);
|
||||
STDMETHOD(SetCompleted)(const UINT64 *completeValue);
|
||||
|
||||
// IArchiveUpdateCallback
|
||||
// STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
|
||||
STDMETHOD(GetUpdateItemInfo)(UINT32 index,
|
||||
INT32 *newData, // 1 - new data, 0 - old data
|
||||
INT32 *newProperties, // 1 - new properties, 0 - old properties
|
||||
UINT32 *indexInArchive// set if existInArchive == true
|
||||
);
|
||||
|
||||
STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value);
|
||||
|
||||
STDMETHOD(GetStream)(UINT32 index, IInStream **anInStream);
|
||||
STDMETHOD(SetOperationResult)(INT32 operationResult);
|
||||
STDMETHOD(CryptoGetTextPassword2)(INT32 *passwordIsDefined, BSTR *password);
|
||||
|
||||
private:
|
||||
UString m_BaseFolderPrefix;
|
||||
const CObjectVector<CDirItem> *m_DirItems;
|
||||
const CObjectVector<CArchiveItem> *m_ArchiveItems;
|
||||
const CObjectVector<CUpdatePair2> *m_UpdatePairs;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> m_UpdateCallback;
|
||||
CMyComPtr<ICryptoGetTextPassword2> _cryptoGetTextPassword;
|
||||
UINT m_CodePage;
|
||||
|
||||
CMyComPtr<IInArchive> _inArchive;
|
||||
|
||||
public:
|
||||
void Init(const UString &baseFolderPrefix,
|
||||
const CObjectVector<CDirItem> *dirItems,
|
||||
const CObjectVector<CArchiveItem> *archiveItems, // test CItemInfoExList
|
||||
CObjectVector<CUpdatePair2> *updatePairs,
|
||||
// UINT codePage,
|
||||
IInArchive *inArchive,
|
||||
IFolderArchiveUpdateCallback *updateCallback);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,65 +1,13 @@
|
||||
// IFolderArchive.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __IFOLDERARCHIVE_H
|
||||
#define __IFOLDERARCHIVE_H
|
||||
#ifndef __IFOLDER_ARCHIVE_H
|
||||
#define __IFOLDER_ARCHIVE_H
|
||||
|
||||
#include "../../Archive/IArchive.h"
|
||||
// #include "../Format/Common/ArchiveInterface.h"
|
||||
#include "../../FileManager/IFolder.h"
|
||||
|
||||
namespace NExtractionMode {
|
||||
namespace NPath
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kFullPathnames,
|
||||
kCurrentPathnames,
|
||||
kNoPathnames
|
||||
};
|
||||
}
|
||||
namespace NOverwrite
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kAskBefore,
|
||||
kWithoutPrompt,
|
||||
kSkipExisting,
|
||||
kAutoRename
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace NOverwriteAnswer
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kYes,
|
||||
kYesToAll,
|
||||
kNo,
|
||||
kNoToAll,
|
||||
kAutoRename,
|
||||
kCancel,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// {23170F69-40C1-278A-0000-000100070000}
|
||||
DEFINE_GUID(IID_IFolderArchiveExtractCallback,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-000100070000")
|
||||
IFolderArchiveExtractCallback: public IProgress
|
||||
{
|
||||
public:
|
||||
STDMETHOD(AskOverwrite)(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize,
|
||||
INT32 *answer);
|
||||
STDMETHOD(PrepareOperation)(const wchar_t *name, INT32 askExtractMode) PURE;
|
||||
STDMETHOD(MessageError)(const wchar_t *message) PURE;
|
||||
STDMETHOD(SetOperationResult)(INT32 operationResult) PURE;
|
||||
};
|
||||
#include "../Common/IFileExtractCallback.h"
|
||||
#include "../Common/ExtractMode.h"
|
||||
|
||||
// {23170F69-40C1-278A-0000-000100050000}
|
||||
DEFINE_GUID(IID_IArchiveFolder,
|
||||
@@ -69,8 +17,8 @@ IArchiveFolder: public IUnknown
|
||||
{
|
||||
public:
|
||||
STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2) PURE;
|
||||
@@ -100,8 +48,8 @@ public:
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
|
||||
STDMETHOD(BindToRootFolder)(IFolderFolder **resultFolder) PURE;
|
||||
STDMETHOD(Extract)(
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2) PURE;
|
||||
@@ -117,6 +65,7 @@ public:
|
||||
STDMETHOD(CompressOperation)(const wchar_t *name) PURE;
|
||||
STDMETHOD(DeleteOperation)(const wchar_t *name) PURE;
|
||||
STDMETHOD(OperationResult)(INT32 operationResult) PURE;
|
||||
STDMETHOD(UpdateErrorMessage)(const wchar_t *message) PURE;
|
||||
};
|
||||
|
||||
// {23170F69-40C1-278A-0000-0001000A0000}
|
||||
@@ -133,7 +82,7 @@ IOutFolderArchive: public IUnknown
|
||||
const wchar_t *filePath,
|
||||
const CLSID *clsID,
|
||||
const wchar_t *newArchiveName,
|
||||
const BYTE *stateActions,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback) PURE;
|
||||
};
|
||||
|
||||
80
7zip/UI/Agent/UpdateCallbackAgent.cpp
Executable file
80
7zip/UI/Agent/UpdateCallbackAgent.cpp
Executable file
@@ -0,0 +1,80 @@
|
||||
// UpdateCallbackAgent.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "UpdateCallbackAgent.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetTotal(UINT64 size)
|
||||
{
|
||||
if (Callback)
|
||||
return Callback->SetTotal(size);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetCompleted(const UINT64 *completeValue)
|
||||
{
|
||||
if (Callback)
|
||||
return Callback->SetCompleted(completeValue);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::CheckBreak()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::Finilize()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::OpenFileError(const wchar_t *name, DWORD systemError)
|
||||
{
|
||||
// if (systemError == ERROR_SHARING_VIOLATION)
|
||||
{
|
||||
if (Callback)
|
||||
{
|
||||
RINOK(Callback->UpdateErrorMessage(
|
||||
UString(L"WARNING: ") +
|
||||
NError::MyFormatMessageW(systemError) +
|
||||
UString(L": ") +
|
||||
UString(name)));
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
// FailedFiles.Add(name);
|
||||
return systemError;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::GetStream(const wchar_t *name, bool isAnti)
|
||||
{
|
||||
if (Callback)
|
||||
return Callback->CompressOperation(name);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetOperationResult(INT32 operationResult)
|
||||
{
|
||||
if (Callback)
|
||||
return Callback->OperationResult(operationResult);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::CryptoGetTextPassword2(INT32 *passwordIsDefined, BSTR *password)
|
||||
{
|
||||
*passwordIsDefined = BoolToInt(false);
|
||||
if (!_cryptoGetTextPassword)
|
||||
{
|
||||
if (!Callback)
|
||||
return S_OK;
|
||||
HRESULT result = Callback.QueryInterface(
|
||||
IID_ICryptoGetTextPassword2, &_cryptoGetTextPassword);
|
||||
if (result != S_OK)
|
||||
return S_OK;
|
||||
}
|
||||
return _cryptoGetTextPassword->CryptoGetTextPassword2(passwordIsDefined, password);
|
||||
}
|
||||
24
7zip/UI/Agent/UpdateCallbackAgent.h
Executable file
24
7zip/UI/Agent/UpdateCallbackAgent.h
Executable file
@@ -0,0 +1,24 @@
|
||||
// UpdateCallbackAgent.h
|
||||
|
||||
#ifndef __UPDATECALLBACKAGENT_H
|
||||
#define __UPDATECALLBACKAGENT_H
|
||||
|
||||
#include "../Common/UpdateCallback.h"
|
||||
#include "IFolderArchive.h"
|
||||
|
||||
class CUpdateCallbackAgent: public IUpdateCallbackUI
|
||||
{
|
||||
virtual HRESULT SetTotal(UINT64 size);
|
||||
virtual HRESULT SetCompleted(const UINT64 *completeValue);
|
||||
virtual HRESULT CheckBreak();
|
||||
virtual HRESULT Finilize();
|
||||
virtual HRESULT GetStream(const wchar_t *name, bool isAnti);
|
||||
virtual HRESULT OpenFileError(const wchar_t *name, DWORD systemError);
|
||||
virtual HRESULT SetOperationResult(INT32 operationResult);
|
||||
virtual HRESULT CryptoGetTextPassword2(INT32 *passwordIsDefined, BSTR *password);
|
||||
CMyComPtr<ICryptoGetTextPassword2> _cryptoGetTextPassword;
|
||||
public:
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> Callback;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user