mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 13:54:54 +02:00
Refactoring for optimizing/simplifying the code for getting plugin root path
This commit is contained in:
parent
4fa910c74b
commit
8dea25feb5
@ -398,23 +398,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||||||
_scintillaCtrls4Plugins.init(_pPublicInterface->getHinst(), hwnd);
|
_scintillaCtrls4Plugins.init(_pPublicInterface->getHinst(), hwnd);
|
||||||
_pluginsManager.init(nppData);
|
_pluginsManager.init(nppData);
|
||||||
|
|
||||||
// If Notepad++ is not in localConf mode, load plugins firstly from "%APPDATA%/Local/Notepad++/plugins"
|
_pluginsManager.loadPluginsV2(pNppParam->getPluginRootDir());
|
||||||
// All the dll loaded are marked.
|
|
||||||
generic_string localAppDataNppPluginsDir = pNppParam->getLocalAppDataNppDir();
|
|
||||||
if (!localAppDataNppPluginsDir.empty() && !pNppParam->isLocal())
|
|
||||||
{
|
|
||||||
PathAppend(localAppDataNppPluginsDir, TEXT("plugins"));
|
|
||||||
_pluginsManager.loadPluginsV2(localAppDataNppPluginsDir.c_str());
|
|
||||||
}
|
|
||||||
else // localConf mode
|
|
||||||
{
|
|
||||||
// Load plugins from its installation directory.
|
|
||||||
// All loaded dll will be ignored
|
|
||||||
_pluginsManager.loadPluginsV2();
|
|
||||||
}
|
|
||||||
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
||||||
|
|
||||||
|
|
||||||
// ------------ //
|
// ------------ //
|
||||||
// Menu Section //
|
// Menu Section //
|
||||||
// ------------ //
|
// ------------ //
|
||||||
|
@ -1015,6 +1015,9 @@ bool NppParameters::load()
|
|||||||
if (_isLocal)
|
if (_isLocal)
|
||||||
{
|
{
|
||||||
_userPath = _nppPath;
|
_userPath = _nppPath;
|
||||||
|
|
||||||
|
_pluginRootDir = _nppPath;
|
||||||
|
PathAppend(_pluginRootDir, TEXT("plugins"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1032,6 +1035,12 @@ bool NppParameters::load()
|
|||||||
PathAppend(_localAppdataNppDir, TEXT("Notepad++"));
|
PathAppend(_localAppdataNppDir, TEXT("Notepad++"));
|
||||||
if (!PathFileExists(_localAppdataNppDir.c_str()))
|
if (!PathFileExists(_localAppdataNppDir.c_str()))
|
||||||
::CreateDirectory(_localAppdataNppDir.c_str(), NULL);
|
::CreateDirectory(_localAppdataNppDir.c_str(), NULL);
|
||||||
|
|
||||||
|
_pluginRootDir = _localAppdataNppDir;
|
||||||
|
PathAppend(_pluginRootDir, TEXT("plugins"));
|
||||||
|
|
||||||
|
if (!PathFileExists(_pluginRootDir.c_str()))
|
||||||
|
::CreateDirectory(_pluginRootDir.c_str(), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1493,11 +1493,13 @@ public:
|
|||||||
generic_string getContextMenuPath() const {return _contextMenuPath;};
|
generic_string getContextMenuPath() const {return _contextMenuPath;};
|
||||||
const TCHAR * getAppDataNppDir() const {return _appdataNppDir.c_str();};
|
const TCHAR * getAppDataNppDir() const {return _appdataNppDir.c_str();};
|
||||||
const TCHAR * getLocalAppDataNppDir() const { return _localAppdataNppDir.c_str(); };
|
const TCHAR * getLocalAppDataNppDir() const { return _localAppdataNppDir.c_str(); };
|
||||||
|
const TCHAR * getPluginRootDir() const { return _pluginRootDir.c_str(); };
|
||||||
const TCHAR * getWorkingDir() const {return _currentDirectory.c_str();};
|
const TCHAR * getWorkingDir() const {return _currentDirectory.c_str();};
|
||||||
const TCHAR * getWorkSpaceFilePath(int i) const {
|
const TCHAR * getWorkSpaceFilePath(int i) const {
|
||||||
if (i < 0 || i > 2) return nullptr;
|
if (i < 0 || i > 2) return nullptr;
|
||||||
return _workSpaceFilePathes[i].c_str();
|
return _workSpaceFilePathes[i].c_str();
|
||||||
}
|
};
|
||||||
|
|
||||||
const std::vector<generic_string> getFileBrowserRoots() const { return _fileBrowserRoot; };
|
const std::vector<generic_string> getFileBrowserRoots() const { return _fileBrowserRoot; };
|
||||||
void setWorkSpaceFilePath(int i, const TCHAR *wsFile);
|
void setWorkSpaceFilePath(int i, const TCHAR *wsFile);
|
||||||
|
|
||||||
@ -1722,7 +1724,8 @@ private:
|
|||||||
generic_string _userPath;
|
generic_string _userPath;
|
||||||
generic_string _stylerPath;
|
generic_string _stylerPath;
|
||||||
generic_string _appdataNppDir; // sentinel of the absence of "doLocalConf.xml" : (_appdataNppDir == TEXT(""))?"doLocalConf.xml present":"doLocalConf.xml absent"
|
generic_string _appdataNppDir; // sentinel of the absence of "doLocalConf.xml" : (_appdataNppDir == TEXT(""))?"doLocalConf.xml present":"doLocalConf.xml absent"
|
||||||
generic_string _localAppdataNppDir; // for plugins
|
generic_string _localAppdataNppDir; // "%LOCALAPPDATA%\Notepad++"
|
||||||
|
generic_string _pluginRootDir;
|
||||||
generic_string _currentDirectory;
|
generic_string _currentDirectory;
|
||||||
generic_string _workSpaceFilePathes[3];
|
generic_string _workSpaceFilePathes[3];
|
||||||
|
|
||||||
|
@ -462,30 +462,6 @@ generic_string PluginsAdminDlg::getPluginConfigPath() const
|
|||||||
return nppPluginsConfDir;
|
return nppPluginsConfDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_string PluginsAdminDlg::getPluginsPath() const
|
|
||||||
{
|
|
||||||
NppParameters *pNppParameters = NppParameters::getInstance();
|
|
||||||
generic_string nppPluginsDir;
|
|
||||||
|
|
||||||
if (pNppParameters->isLocal())
|
|
||||||
{
|
|
||||||
nppPluginsDir = pNppParameters->getNppPath();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nppPluginsDir = pNppParameters->getLocalAppDataNppDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
PathAppend(nppPluginsDir, TEXT("plugins"));
|
|
||||||
|
|
||||||
if (!::PathFileExists(nppPluginsDir.c_str()))
|
|
||||||
{
|
|
||||||
::CreateDirectory(nppPluginsDir.c_str(), NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nppPluginsDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PluginsAdminDlg::exitToInstallRemovePlugins(Operation op, const vector<PluginUpdateInfo*>& puis)
|
bool PluginsAdminDlg::exitToInstallRemovePlugins(Operation op, const vector<PluginUpdateInfo*>& puis)
|
||||||
{
|
{
|
||||||
generic_string opStr;
|
generic_string opStr;
|
||||||
@ -513,7 +489,7 @@ bool PluginsAdminDlg::exitToInstallRemovePlugins(Operation op, const vector<Plug
|
|||||||
updaterParams += TEXT("\" ");
|
updaterParams += TEXT("\" ");
|
||||||
|
|
||||||
updaterParams += TEXT("\"");
|
updaterParams += TEXT("\"");
|
||||||
updaterParams += getPluginsPath();
|
updaterParams += pNppParameters->getPluginRootDir();
|
||||||
updaterParams += TEXT("\"");
|
updaterParams += TEXT("\"");
|
||||||
|
|
||||||
for (auto i : puis)
|
for (auto i : puis)
|
||||||
|
@ -182,7 +182,6 @@ public :
|
|||||||
|
|
||||||
bool updateListAndLoadFromJson();
|
bool updateListAndLoadFromJson();
|
||||||
void setAdminMode(bool isAdm) { _nppCurrentStatus._isAdminMode = isAdm; };
|
void setAdminMode(bool isAdm) { _nppCurrentStatus._isAdminMode = isAdm; };
|
||||||
generic_string getPluginsPath() const;
|
|
||||||
generic_string getPluginConfigPath() const;
|
generic_string getPluginConfigPath() const;
|
||||||
|
|
||||||
bool installPlugins();
|
bool installPlugins();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user