mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 07:14:56 -06:00
4.45 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
d9666cf046
commit
a145bfc7cf
@@ -13,10 +13,6 @@
|
||||
|
||||
#include "Agent.h"
|
||||
|
||||
#ifdef FORMAT_7Z
|
||||
#include "../../Archive/7z/7zHandler.h"
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Sort.h"
|
||||
@@ -407,7 +403,8 @@ STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
|
||||
// CAgent
|
||||
|
||||
CAgent::CAgent():
|
||||
_proxyArchive(NULL)
|
||||
_proxyArchive(NULL),
|
||||
_codecs(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -430,11 +427,17 @@ STDMETHODIMP CAgent::Open(
|
||||
return ::GetLastError();
|
||||
if (fileInfo.IsDirectory())
|
||||
return E_FAIL;
|
||||
CArchiverInfo archiverInfo0, archiverInfo1;
|
||||
HRESULT res = OpenArchive(_archiveFilePath, _archiveLink, openArchiveCallback);
|
||||
CArcInfoEx archiverInfo0, archiverInfo1;
|
||||
|
||||
_compressCodecsInfo.Release();
|
||||
_codecs = new CCodecs;
|
||||
_compressCodecsInfo = _codecs;
|
||||
RINOK(_codecs->Load());
|
||||
|
||||
HRESULT res = OpenArchive(_codecs, _archiveFilePath, _archiveLink, openArchiveCallback);
|
||||
// _archive = _archiveLink.GetArchive();
|
||||
DefaultName = _archiveLink.GetDefaultItemName();
|
||||
const CArchiverInfo &ai = _archiveLink.GetArchiverInfo();
|
||||
const CArcInfoEx &ai = _codecs->Formats[_archiveLink.GetArchiverIndex()];
|
||||
|
||||
RINOK(res);
|
||||
DefaultTime = fileInfo.LastWriteTime;
|
||||
@@ -449,9 +452,7 @@ STDMETHODIMP CAgent::Open(
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::ReOpen(
|
||||
// const wchar_t *filePath,
|
||||
IArchiveOpenCallback * /* openArchiveCallback */)
|
||||
STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback * /* openArchiveCallback */)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
if (_proxyArchive != NULL)
|
||||
@@ -459,7 +460,7 @@ STDMETHODIMP CAgent::ReOpen(
|
||||
delete _proxyArchive;
|
||||
_proxyArchive = NULL;
|
||||
}
|
||||
RINOK(ReOpenArchive(_archiveLink, _archiveFilePath));
|
||||
RINOK(ReOpenArchive(_codecs, _archiveLink, _archiveFilePath));
|
||||
return ReadItems();
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -7,17 +7,14 @@
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/UpdateAction.h"
|
||||
#include "../Common/ArchiverInfo.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "IFolderArchive.h"
|
||||
#include "AgentProxy.h"
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "Windows/DLL.h"
|
||||
#endif
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
#include "../../FileManager/IFolder.h"
|
||||
#include "../Common/LoadCodecs.h"
|
||||
#endif
|
||||
|
||||
class CAgentFolder;
|
||||
@@ -184,21 +181,10 @@ public:
|
||||
|
||||
STDMETHOD(Open)(
|
||||
const wchar_t *filePath,
|
||||
// CLSID *clsIDResult,
|
||||
BSTR *archiveType,
|
||||
IArchiveOpenCallback *openArchiveCallback);
|
||||
|
||||
STDMETHOD(ReOpen)(
|
||||
// const wchar_t *filePath,
|
||||
IArchiveOpenCallback *openArchiveCallback);
|
||||
/*
|
||||
STDMETHOD(ReOpen)(IInStream *stream,
|
||||
const wchar_t *defaultName,
|
||||
const FILETIME *defaultTime,
|
||||
UINT32 defaultAttributes,
|
||||
const UINT64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *openArchiveCallback);
|
||||
*/
|
||||
STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback);
|
||||
STDMETHOD(Close)();
|
||||
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
|
||||
@@ -221,8 +207,13 @@ public:
|
||||
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName, const UINT32 *indices,
|
||||
UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback);
|
||||
STDMETHOD(DoOperation)(
|
||||
const wchar_t *filePath,
|
||||
const CLSID *clsID,
|
||||
CCodecs *codecs,
|
||||
int formatIndex,
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback);
|
||||
STDMETHOD(DoOperation2)(
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
@@ -248,6 +239,9 @@ public:
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, INT32 numProperties);
|
||||
#endif
|
||||
|
||||
CCodecs *_codecs;
|
||||
CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo;
|
||||
|
||||
CAgent();
|
||||
~CAgent();
|
||||
private:
|
||||
@@ -288,26 +282,22 @@ public:
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
class CArchiveFolderManager:
|
||||
public IFolderManager,
|
||||
public IFolderManagerGetIconPath,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP2(
|
||||
IFolderManager,
|
||||
IFolderManagerGetIconPath
|
||||
)
|
||||
MY_UNKNOWN_IMP1(IFolderManager)
|
||||
// IFolderManager
|
||||
STDMETHOD(OpenFolderFile)(const wchar_t *filePath, IFolderFolder **resultFolder, IProgress *progress);
|
||||
STDMETHOD(GetTypes)(BSTR *types);
|
||||
STDMETHOD(GetExtension)(const wchar_t *type, BSTR *extension);
|
||||
STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress);
|
||||
STDMETHOD(GetIconPath)(const wchar_t *type, BSTR *iconPath);
|
||||
CArchiveFolderManager(): _formatsLoaded(false) {}
|
||||
STDMETHOD(GetExtensions)(BSTR *extensions);
|
||||
STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex);
|
||||
// STDMETHOD(GetTypes)(BSTR *types);
|
||||
// STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress);
|
||||
CArchiveFolderManager(): _codecs(0) {}
|
||||
private:
|
||||
void LoadFormats();
|
||||
int FindFormat(const UString &type);
|
||||
bool _formatsLoaded;
|
||||
CObjectVector<CArchiverInfo> _formats;
|
||||
CCodecs *_codecs;
|
||||
CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -141,8 +141,8 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::DoOperation(
|
||||
const wchar_t *filePath,
|
||||
const CLSID *clsID,
|
||||
CCodecs *codecs,
|
||||
int formatIndex,
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
@@ -167,8 +167,6 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
return errorCodes.Front();
|
||||
}
|
||||
|
||||
NWindows::NDLL::CLibrary library;
|
||||
|
||||
CMyComPtr<IOutArchive> outArchive;
|
||||
if (GetArchive())
|
||||
{
|
||||
@@ -176,9 +174,20 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
}
|
||||
else
|
||||
{
|
||||
CHandlerLoader loader;
|
||||
RINOK(loader.CreateHandler(filePath, *clsID, (void **)&outArchive, true));
|
||||
library.Attach(loader.Detach());
|
||||
if (formatIndex < 0)
|
||||
return E_FAIL;
|
||||
RINOK(codecs->CreateOutArchive(formatIndex, outArchive));
|
||||
#ifdef EXTERNAL_CODECS
|
||||
{
|
||||
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
|
||||
outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
NFileTimeType::EEnum fileTimeType;
|
||||
@@ -281,6 +290,15 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
return outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback);
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::DoOperation2(
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
return DoOperation(_codecs, -1, newArchiveName,
|
||||
stateActions, sfxModule, updateCallback100);
|
||||
}
|
||||
|
||||
HRESULT CAgent::CommonUpdate(
|
||||
const wchar_t *newArchiveName,
|
||||
|
||||
@@ -15,15 +15,17 @@ static inline UINT GetCurrentFileCodePage()
|
||||
|
||||
void CArchiveFolderManager::LoadFormats()
|
||||
{
|
||||
if (!_formatsLoaded)
|
||||
ReadArchiverInfoList(_formats);
|
||||
if (!_codecs)
|
||||
{
|
||||
_compressCodecsInfo = _codecs = new CCodecs;
|
||||
_codecs->Load();
|
||||
}
|
||||
}
|
||||
|
||||
int CArchiveFolderManager::FindFormat(const UString &type)
|
||||
{
|
||||
// LoadFormats();
|
||||
for (int i = 0; i < _formats.Size(); i++)
|
||||
if (type.CompareNoCase(_formats[i].Name) == 0)
|
||||
for (int i = 0; i < _codecs->Formats.Size(); i++)
|
||||
if (type.CompareNoCase(_codecs->Formats[i].Name) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
@@ -51,14 +53,68 @@ HRESULT CAgent::FolderReOpen(
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *extensions)
|
||||
{
|
||||
*extensions = 0;
|
||||
int formatIndex = FindFormat(type);
|
||||
if (formatIndex < 0)
|
||||
return E_INVALIDARG;
|
||||
CMyComBSTR valueTemp = _codecs.Formats[formatIndex].GetAllExtensions(); // Exts[0].Ext;
|
||||
*extensions = valueTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
|
||||
{
|
||||
LoadFormats();
|
||||
*extensions = 0;
|
||||
UString res;
|
||||
for (int i = 0; i < _codecs->Libs.Size(); i++)
|
||||
{
|
||||
const CCodecLib &lib = _codecs->Libs[i];
|
||||
for (int j = 0; j < lib.IconPairs.Size(); j++)
|
||||
{
|
||||
if (!res.IsEmpty())
|
||||
res += L' ';
|
||||
res += lib.IconPairs[j].Ext;
|
||||
}
|
||||
}
|
||||
CMyComBSTR valueTemp = res;
|
||||
*extensions = valueTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)
|
||||
{
|
||||
LoadFormats();
|
||||
*iconPath = 0;
|
||||
*iconIndex = 0;
|
||||
for (int i = 0; i < _codecs->Libs.Size(); i++)
|
||||
{
|
||||
const CCodecLib &lib = _codecs->Libs[i];
|
||||
int ii = lib.FindIconIndex(ext);
|
||||
if (ii >= 0)
|
||||
{
|
||||
CMyComBSTR iconPathTemp = GetUnicodeString(lib.Path, GetCurrentFileCodePage());
|
||||
*iconIndex = ii;
|
||||
*iconPath = iconPathTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
|
||||
{
|
||||
LoadFormats();
|
||||
UString typesStrings;
|
||||
for(int i = 0; i < _formats.Size(); i++)
|
||||
for(int i = 0; i < _codecs.Formats.Size(); i++)
|
||||
{
|
||||
const CArchiverInfo &ai = _formats[i];
|
||||
if (!ai.Associate)
|
||||
const CArcInfoEx &ai = _codecs.Formats[i];
|
||||
if (ai.AssociateExts.Size() == 0)
|
||||
continue;
|
||||
if (i != 0)
|
||||
typesStrings += L' ';
|
||||
@@ -68,31 +124,9 @@ STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
|
||||
*types = valueTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveFolderManager::GetExtension(const wchar_t *type, BSTR *extension)
|
||||
{
|
||||
*extension = 0;
|
||||
int formatIndex = FindFormat(type);
|
||||
if (formatIndex < 0)
|
||||
return E_INVALIDARG;
|
||||
CMyComBSTR valueTemp = _formats[formatIndex].Extensions[0].Ext;
|
||||
*extension = valueTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *type, BSTR *iconPath)
|
||||
{
|
||||
*iconPath = 0;
|
||||
int formatIndex = FindFormat(type);
|
||||
if (formatIndex < 0)
|
||||
return E_INVALIDARG;
|
||||
CMyComBSTR iconPathTemp = _formats[formatIndex].FilePath;
|
||||
*iconPath = iconPathTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * /* type */,
|
||||
const wchar_t * /* filePath */, IProgress * /* progress */)
|
||||
STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
|
||||
const wchar_t * filePath, IProgress progress)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -88,8 +88,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (Byte)actionSet->StateActions[i];
|
||||
result = _agentSpec->DoOperation(NULL, NULL,
|
||||
tempFileName, actionSetByte, NULL, updateCallback100);
|
||||
result = _agentSpec->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback100);
|
||||
}
|
||||
|
||||
if (result != S_OK)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../../FileManager/IFolder.h"
|
||||
#include "../Common/IFileExtractCallback.h"
|
||||
#include "../Common/ExtractMode.h"
|
||||
#include "../../UI/Common/LoadCodecs.h"
|
||||
|
||||
// {23170F69-40C1-278A-0000-000100050000}
|
||||
DEFINE_GUID(IID_IArchiveFolder,
|
||||
@@ -31,7 +32,8 @@ MIDL_INTERFACE("23170F69-40C1-278A-0000-000100060000")
|
||||
IInFolderArchive: public IUnknown
|
||||
{
|
||||
public:
|
||||
STDMETHOD(Open)(const wchar_t *filePath,
|
||||
STDMETHOD(Open)(
|
||||
const wchar_t *filePath,
|
||||
// CLSID *clsIDResult,
|
||||
BSTR *archiveType,
|
||||
IArchiveOpenCallback *openArchiveCallback) PURE;
|
||||
@@ -68,10 +70,9 @@ public:
|
||||
STDMETHOD(UpdateErrorMessage)(const wchar_t *message) PURE;
|
||||
};
|
||||
|
||||
// {23170F69-40C1-278A-0000-0001000A0000}
|
||||
DEFINE_GUID(IID_IOutFolderArchive,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x00);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-0001000A0000")
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x02);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-0001000A0002")
|
||||
IOutFolderArchive: public IUnknown
|
||||
{
|
||||
STDMETHOD(SetFolder)(IFolderFolder *folder) PURE;
|
||||
@@ -79,8 +80,13 @@ IOutFolderArchive: public IUnknown
|
||||
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName,
|
||||
const UINT32 *indices, UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback) PURE;
|
||||
STDMETHOD(DoOperation)(
|
||||
const wchar_t *filePath,
|
||||
const CLSID *clsID,
|
||||
CCodecs *codecs,
|
||||
int index,
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback) PURE;
|
||||
STDMETHOD(DoOperation2)(
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
|
||||
Reference in New Issue
Block a user