blob: 556c54fd06ecac95a61094f53516124923c64a61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// FilePlugins.cpp
#include "StdAfx.h"
#include "../Agent/Agent.h"
#include "FilePlugins.h"
#include "PluginLoader.h"
#include "StringUtils.h"
int CExtDatabase::FindExt(const UString &ext)
{
FOR_VECTOR (i, Exts)
if (Exts[i].Ext.IsEqualToNoCase(ext))
return i;
return -1;
}
void CExtDatabase::Read()
{
ReadFileFolderPluginInfoList(Plugins);
FOR_VECTOR (pluginIndex, Plugins)
{
const CPluginInfo &plugin = Plugins[pluginIndex];
CPluginLibrary pluginLib;
CMyComPtr<IFolderManager> folderManager;
if (plugin.FilePath.IsEmpty())
folderManager = new CArchiveFolderManager;
else if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
continue;
CMyComBSTR extBSTR;
if (folderManager->GetExtensions(&extBSTR) != S_OK)
return;
UStringVector exts;
SplitString((const wchar_t *)extBSTR, exts);
FOR_VECTOR (i, exts)
{
const UString &ext = exts[i];
#ifdef UNDER_CE
if (ext == L"cab")
continue;
#endif
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
{
CExtPlugins extInfo;
extInfo.Plugins.Add(plugPair);
extInfo.Ext = ext;
Exts.Add(extInfo);
}
}
}
}
|