Plugin name should match to plugin folder name
Load plugin only when plugin name match to plugin folder name. For example: "NppPluginDemo.dll" can be loaded only when it in the folder named "NppPluginDemo".
This commit is contained in:
parent
2c9f096d6d
commit
4c2e41b649
@ -359,38 +359,42 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir)
|
||||
WIN32_FIND_DATA foundData;
|
||||
HANDLE hFindFolder = ::FindFirstFile(pluginsFolderFilter.c_str(), &foundData);
|
||||
HANDLE hFindDll = INVALID_HANDLE_VALUE;
|
||||
|
||||
// get plugin folder
|
||||
if (hFindFolder != INVALID_HANDLE_VALUE && (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
generic_string pluginsFullPathFilter = dir;
|
||||
PathAppend(pluginsFullPathFilter, foundData.cFileName);
|
||||
generic_string pluginsFolderPath = pluginsFullPathFilter;
|
||||
PathAppend(pluginsFullPathFilter, TEXT("*.dll"));
|
||||
generic_string dllName = foundData.cFileName;
|
||||
dllName += TEXT(".dll");
|
||||
PathAppend(pluginsFullPathFilter, dllName);
|
||||
|
||||
// get plugin
|
||||
hFindDll = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData);
|
||||
if (hFindDll != INVALID_HANDLE_VALUE && !(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
generic_string pluginsFullPath = pluginsFolderPath;
|
||||
PathAppend(pluginsFullPath, foundData.cFileName);
|
||||
dllNames.push_back(pluginsFullPath);
|
||||
dllNames.push_back(pluginsFullPathFilter);
|
||||
|
||||
PluginList & pl = nppParams->getPluginList();
|
||||
pl.add(foundData.cFileName, false);
|
||||
}
|
||||
|
||||
// get plugin folder
|
||||
while (::FindNextFile(hFindFolder, &foundData))
|
||||
{
|
||||
|
||||
generic_string pluginsFullPathFilter2 = dir;
|
||||
PathAppend(pluginsFullPathFilter2, foundData.cFileName);
|
||||
generic_string pluginsFolderPath2 = pluginsFullPathFilter2;
|
||||
PathAppend(pluginsFullPathFilter2, TEXT("*.dll"));
|
||||
generic_string dllName2 = foundData.cFileName;
|
||||
dllName2 += TEXT(".dll");
|
||||
PathAppend(pluginsFullPathFilter2, dllName2);
|
||||
|
||||
// get plugin
|
||||
hFindDll = ::FindFirstFile(pluginsFullPathFilter2.c_str(), &foundData);
|
||||
if (hFindDll != INVALID_HANDLE_VALUE && !(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
generic_string pluginsFullPath2 = pluginsFolderPath2;
|
||||
PathAppend(pluginsFullPath2, foundData.cFileName);
|
||||
dllNames.push_back(pluginsFullPath2);
|
||||
dllNames.push_back(pluginsFullPathFilter2);
|
||||
|
||||
PluginList & pl = nppParams->getPluginList();
|
||||
pl.add(foundData.cFileName, false);
|
||||
|
Loading…
Reference in New Issue
Block a user