mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-14 08:11:35 -06:00
9.21
This commit is contained in:
committed by
Kornel Lesiński
parent
de4f8c22fe
commit
35596517f2
@@ -2,73 +2,39 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "FilePlugins.h"
|
||||
#include "PluginLoader.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
using namespace NRegistryAssociations;
|
||||
|
||||
int CExtDatabase::FindExtInfoBig(const UString &ext)
|
||||
int CExtDatabase::FindExt(const UString &ext)
|
||||
{
|
||||
for (int i = 0; i < ExtBigItems.Size(); i++)
|
||||
if (ExtBigItems[i].Ext.CompareNoCase(ext) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CExtDatabase::FindPlugin(const UString &plugin)
|
||||
{
|
||||
for (int i = 0; i < Plugins.Size(); i++)
|
||||
if (Plugins[i].Name.CompareNoCase(plugin) == 0)
|
||||
for (int i = 0; i < Exts.Size(); i++)
|
||||
if (Exts[i].Ext.CompareNoCase(ext) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CExtDatabase::Read()
|
||||
{
|
||||
/*
|
||||
CObjectVector<CExtInfo> extItems;
|
||||
ReadInternalAssociations(extItems);
|
||||
*/
|
||||
ReadFileFolderPluginInfoList(Plugins);
|
||||
/*
|
||||
for (int i = 0; i < extItems.Size(); i++)
|
||||
{
|
||||
const CExtInfo &extInfo = extItems[i];
|
||||
CExtInfoBig extInfoBig;
|
||||
extInfoBig.Ext = extInfo.Ext;
|
||||
extInfoBig.Associated = false;
|
||||
for (int p = 0; p < extInfo.Plugins.Size(); p++)
|
||||
{
|
||||
int pluginIndex = FindPlugin(extInfo.Plugins[p]);
|
||||
if (pluginIndex >= 0)
|
||||
extInfoBig.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, true));
|
||||
}
|
||||
ExtBigItems.Add(extInfoBig);
|
||||
}
|
||||
*/
|
||||
for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++)
|
||||
{
|
||||
const CPluginInfo &pluginInfo = Plugins[pluginIndex];
|
||||
const CPluginInfo &plugin = Plugins[pluginIndex];
|
||||
|
||||
CPluginLibrary pluginLibrary;
|
||||
CPluginLibrary pluginLib;
|
||||
CMyComPtr<IFolderManager> folderManager;
|
||||
|
||||
if (pluginInfo.FilePath.IsEmpty())
|
||||
if (plugin.FilePath.IsEmpty())
|
||||
folderManager = new CArchiveFolderManager;
|
||||
else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
|
||||
pluginInfo.ClassID, &folderManager) != S_OK)
|
||||
else if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
|
||||
continue;
|
||||
CMyComBSTR extBSTR;
|
||||
if (folderManager->GetExtensions(&extBSTR) != S_OK)
|
||||
return;
|
||||
const UString ext2 = (const wchar_t *)extBSTR;
|
||||
UStringVector exts;
|
||||
SplitString(ext2, exts);
|
||||
SplitString((const wchar_t *)extBSTR, exts);
|
||||
for (int i = 0; i < exts.Size(); i++)
|
||||
{
|
||||
const UString &ext = exts[i];
|
||||
@@ -76,44 +42,28 @@ void CExtDatabase::Read()
|
||||
if (ext == L"cab")
|
||||
continue;
|
||||
#endif
|
||||
int index = FindExtInfoBig(ext);
|
||||
if (index < 0)
|
||||
{
|
||||
CExtInfoBig extInfo;
|
||||
extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
|
||||
extInfo.Associated = false;
|
||||
extInfo.Ext = ext;
|
||||
ExtBigItems.Add(extInfo);
|
||||
}
|
||||
|
||||
Int32 iconIndex;
|
||||
CMyComBSTR iconPath;
|
||||
CPluginToIcon plugPair;
|
||||
plugPair.PluginIndex = pluginIndex;
|
||||
if (folderManager->GetIconPath(ext, &iconPath, &iconIndex) == S_OK)
|
||||
if (iconPath != 0)
|
||||
{
|
||||
plugPair.IconPath = (const wchar_t *)iconPath;
|
||||
plugPair.IconIndex = iconIndex;
|
||||
}
|
||||
|
||||
int index = FindExt(ext);
|
||||
if (index >= 0)
|
||||
Exts[index].Plugins.Add(plugPair);
|
||||
else
|
||||
{
|
||||
CExtInfoBig &extInfo = ExtBigItems[index];
|
||||
int pluginIndexIndex = extInfo.FindPlugin(pluginIndex);
|
||||
if (pluginIndexIndex < 0)
|
||||
extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
|
||||
CExtPlugins extInfo;
|
||||
extInfo.Plugins.Add(plugPair);
|
||||
extInfo.Ext = ext;
|
||||
Exts.Add(extInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CExtDatabase::Save()
|
||||
{
|
||||
/*
|
||||
CObjectVector<CExtInfo> extItems;
|
||||
for (int i = 0; i < ExtBigItems.Size(); i++)
|
||||
{
|
||||
const CExtInfoBig &extInfoBig = ExtBigItems[i];
|
||||
CExtInfo extInfo;
|
||||
// extInfo.Enabled = extInfoBig.Associated;
|
||||
extInfo.Ext = extInfoBig.Ext;
|
||||
for (int p = 0; p < extInfoBig.PluginsPairs.Size(); p++)
|
||||
{
|
||||
CPluginEnabledPair pluginPair = extInfoBig.PluginsPairs[p];
|
||||
if (pluginPair.Enabled)
|
||||
extInfo.Plugins.Add(Plugins[pluginPair.Index].Name);
|
||||
}
|
||||
extItems.Add(extInfo);
|
||||
}
|
||||
WriteInternalAssociations(extItems);
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user