mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-22 21:34:58 +02:00
Make new file system of plugin works on installation directory
This commit is contained in:
parent
a4ac43f141
commit
7cf5232056
@ -345,30 +345,44 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
|
|||||||
|
|
||||||
bool PluginsManager::loadPluginsV2(const TCHAR* dir)
|
bool PluginsManager::loadPluginsV2(const TCHAR* dir)
|
||||||
{
|
{
|
||||||
if (_isDisabled || !dir || !dir[0])
|
if (_isDisabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
NppParameters * nppParams = NppParameters::getInstance();
|
|
||||||
|
|
||||||
vector<generic_string> dllNames;
|
vector<generic_string> dllNames;
|
||||||
vector<generic_string> dll2Remove;
|
vector<generic_string> dll2Remove;
|
||||||
|
|
||||||
generic_string pluginsFolderFilter = dir;
|
NppParameters * nppParams = NppParameters::getInstance();
|
||||||
|
generic_string nppPath = nppParams->getNppPath();
|
||||||
|
|
||||||
|
generic_string pluginsFolder;
|
||||||
|
if (dir && dir[0])
|
||||||
|
{
|
||||||
|
pluginsFolder = dir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pluginsFolder = nppPath;
|
||||||
|
PathAppend(pluginsFolder, TEXT("plugins"));
|
||||||
|
}
|
||||||
|
generic_string pluginsFolderFilter = pluginsFolder;
|
||||||
PathAppend(pluginsFolderFilter, TEXT("*.*"));
|
PathAppend(pluginsFolderFilter, TEXT("*.*"));
|
||||||
|
|
||||||
WIN32_FIND_DATA foundData;
|
WIN32_FIND_DATA foundData;
|
||||||
|
printStr(pluginsFolder.c_str());
|
||||||
HANDLE hFindFolder = ::FindFirstFile(pluginsFolderFilter.c_str(), &foundData);
|
HANDLE hFindFolder = ::FindFirstFile(pluginsFolderFilter.c_str(), &foundData);
|
||||||
HANDLE hFindDll = INVALID_HANDLE_VALUE;
|
HANDLE hFindDll = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
// get plugin folder
|
// get plugin folder
|
||||||
if (hFindFolder != INVALID_HANDLE_VALUE && (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
if (hFindFolder != INVALID_HANDLE_VALUE && (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
generic_string pluginsFullPathFilter = dir;
|
generic_string pluginsFullPathFilter = pluginsFolder;
|
||||||
PathAppend(pluginsFullPathFilter, foundData.cFileName);
|
PathAppend(pluginsFullPathFilter, foundData.cFileName);
|
||||||
generic_string pluginsFolderPath = pluginsFullPathFilter;
|
generic_string pluginsFolderPath = pluginsFullPathFilter;
|
||||||
generic_string dllName = foundData.cFileName;
|
generic_string dllName = foundData.cFileName;
|
||||||
dllName += TEXT(".dll");
|
dllName += TEXT(".dll");
|
||||||
PathAppend(pluginsFullPathFilter, dllName);
|
PathAppend(pluginsFullPathFilter, dllName);
|
||||||
|
printStr(pluginsFullPathFilter.c_str());
|
||||||
|
|
||||||
// get plugin
|
// get plugin
|
||||||
hFindDll = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData);
|
hFindDll = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData);
|
||||||
@ -383,13 +397,13 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir)
|
|||||||
// get plugin folder
|
// get plugin folder
|
||||||
while (::FindNextFile(hFindFolder, &foundData))
|
while (::FindNextFile(hFindFolder, &foundData))
|
||||||
{
|
{
|
||||||
generic_string pluginsFullPathFilter2 = dir;
|
generic_string pluginsFullPathFilter2 = pluginsFolder;
|
||||||
PathAppend(pluginsFullPathFilter2, foundData.cFileName);
|
PathAppend(pluginsFullPathFilter2, foundData.cFileName);
|
||||||
generic_string pluginsFolderPath2 = pluginsFullPathFilter2;
|
generic_string pluginsFolderPath2 = pluginsFullPathFilter2;
|
||||||
generic_string dllName2 = foundData.cFileName;
|
generic_string dllName2 = foundData.cFileName;
|
||||||
dllName2 += TEXT(".dll");
|
dllName2 += TEXT(".dll");
|
||||||
PathAppend(pluginsFullPathFilter2, dllName2);
|
PathAppend(pluginsFullPathFilter2, dllName2);
|
||||||
|
printStr(pluginsFullPathFilter2.c_str());
|
||||||
// get plugin
|
// get plugin
|
||||||
hFindDll = ::FindFirstFile(pluginsFullPathFilter2.c_str(), &foundData);
|
hFindDll = ::FindFirstFile(pluginsFullPathFilter2.c_str(), &foundData);
|
||||||
if (hFindDll != INVALID_HANDLE_VALUE && !(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
if (hFindDll != INVALID_HANDLE_VALUE && !(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
|
|
||||||
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
||||||
bool loadPlugins(const TCHAR *dir = NULL);
|
bool loadPlugins(const TCHAR *dir = NULL);
|
||||||
bool loadPluginsV2(const TCHAR *dir);
|
bool loadPluginsV2(const TCHAR *dir = NULL);
|
||||||
|
|
||||||
bool unloadPlugin(int index, HWND nppHandle);
|
bool unloadPlugin(int index, HWND nppHandle);
|
||||||
|
|
||||||
|
@ -415,6 +415,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||||||
// Load plugins from its installation directory.
|
// Load plugins from its installation directory.
|
||||||
// All loaded dll will be ignored
|
// All loaded dll will be ignored
|
||||||
_pluginsManager.loadPlugins();
|
_pluginsManager.loadPlugins();
|
||||||
|
_pluginsManager.loadPluginsV2();
|
||||||
|
|
||||||
|
|
||||||
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user