Skip to content

Commit 8816d85

Browse files
committed
Change plugin and shared directory location depending on GUI build type
- If GUI is built from source: - Plugin Installer plugins will be installed at executable-level plugins directory - Config and windowState XML files will be at the same level as executable - If GUI is installed using installers/zip: - Same as in v0.5.0
1 parent 8bc78e8 commit 8816d85

File tree

3 files changed

+43
-28
lines changed

3 files changed

+43
-28
lines changed

Source/CoreServices.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,19 @@ namespace CoreServices
245245
#if defined(__APPLE__)
246246
File dir = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile("Application Support/open-ephys");
247247
#elif _WIN32
248-
File dir = File::getSpecialLocation(File::commonApplicationDataDirectory).getChildFile("Open Ephys");
248+
String appDir = File::getSpecialLocation(File::currentApplicationFile).getFullPathName();
249+
File dir;
250+
if(appDir.contains("plugin-GUI\\Build\\"))
251+
dir = File::getSpecialLocation(File::currentApplicationFile).getParentDirectory();
252+
else
253+
dir = File::getSpecialLocation(File::commonApplicationDataDirectory).getChildFile("Open Ephys");
249254
#else
250-
File dir = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile(".open-ephys");;
255+
String appDir = File::getSpecialLocation(File::currentApplicationFile).getFullPathName();
256+
File dir;
257+
if(appDir.contains("plugin-GUI/Build/"))
258+
dir = File::getSpecialLocation(File::currentApplicationFile).getParentDirectory();
259+
else
260+
dir = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile(".open-ephys");;
251261
#endif
252262
if (!dir.isDirectory()) {
253263
dir.createDirectory();

Source/Processors/PluginManager/PluginManager.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,29 @@ static void errorMsg(const char *file, int line, const char *msg) {
7272

7373
PluginManager::PluginManager()
7474
{
75-
#ifdef WIN32
75+
#ifdef _WIN32
76+
77+
String appDir = File::getSpecialLocation(File::currentApplicationFile).getFullPathName();
78+
7679
//Shared directory at the same level as executable
7780
File sharedPath = File::getSpecialLocation(File::currentApplicationFile).getParentDirectory().getChildFile("shared");
78-
SetDllDirectory(sharedPath.getFullPathName().toUTF8());
79-
8081
//Shared directory managed by Plugin Installer at C:/ProgramData
8182
File installSharedPath = File::getSpecialLocation(File::commonApplicationDataDirectory).getChildFile("Open Ephys/shared");
82-
if (!installSharedPath.isDirectory()) {
83-
installSharedPath.createDirectory();
83+
84+
if(appDir.contains("plugin-GUI\\Build\\"))
85+
{
86+
SetDllDirectory(sharedPath.getFullPathName().toUTF8());
87+
}
88+
else
89+
{
90+
if (!installSharedPath.isDirectory())
91+
{
92+
std::cout << "Copying shared dependencies to " << installSharedPath.getFullPathName() << std::endl;
93+
sharedPath.copyDirectoryTo(installSharedPath);
94+
}
95+
SetDllDirectory(installSharedPath.getFullPathName().toUTF8());
8496
}
8597

86-
AddDllDirectory(installSharedPath.getFullPathName().toWideCharPointer());
87-
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
8898
#elif __linux__
8999
File installSharedPath = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile(".open-ephys/shared");
90100
if (!installSharedPath.isDirectory()) {
@@ -107,10 +117,16 @@ void PluginManager::loadAllPlugins()
107117
paths.add(File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile("Application Support/open-ephys/plugins"));
108118
#elif _WIN32
109119
paths.add(File::getSpecialLocation(File::currentApplicationFile).getParentDirectory().getChildFile("plugins"));
110-
paths.add(File::getSpecialLocation(File::commonApplicationDataDirectory).getChildFile("Open Ephys/plugins"));
120+
121+
String appDir = File::getSpecialLocation(File::currentApplicationFile).getFullPathName();
122+
if(!appDir.contains("plugin-GUI\\Build\\"))
123+
paths.add(File::getSpecialLocation(File::commonApplicationDataDirectory).getChildFile("Open Ephys/plugins"));
111124
#else
112125
paths.add(File::getSpecialLocation(File::currentApplicationFile).getParentDirectory().getChildFile("plugins"));
113-
paths.add(File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile(".open-ephys/plugins"));
126+
127+
String appDir = File::getSpecialLocation(File::currentApplicationFile).getFullPathName();
128+
if(!appDir.contains("plugin-GUI/Build/"))
129+
paths.add(File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile(".open-ephys/plugins"));
114130
#endif
115131

116132
for (auto &pluginPath : paths) {

Source/UI/PluginInstaller.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@
3737

3838
//-----------------------------------------------------------------------
3939

40-
static inline File getPluginsLocationDirectory() {
41-
#if defined(__APPLE__)
42-
File dir = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile("Application Support/open-ephys");
43-
#elif _WIN32
44-
File dir = File::getSpecialLocation(File::commonApplicationDataDirectory).getChildFile("Open Ephys");
45-
#else
46-
File dir = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile(".open-ephys");
47-
#endif
48-
return std::move(dir);
49-
}
50-
5140
static String osType;
5241

5342
PluginInstaller::PluginInstaller(MainWindow* mainWindow)
@@ -108,12 +97,12 @@ void PluginInstaller::closeButtonPressed()
10897

10998
void PluginInstaller::createXmlFile()
11099
{
111-
File pluginsDir = getPluginsLocationDirectory().getChildFile("plugins");
100+
File pluginsDir = CoreServices::getSavedStateDirectory().getChildFile("plugins");
112101
if (!pluginsDir.isDirectory())
113102
pluginsDir.createDirectory();
114103

115104
String xmlFile = "plugins" + File::separatorString + "installedPlugins.xml";
116-
File file = getPluginsLocationDirectory().getChildFile(xmlFile);
105+
File file = CoreServices::getSavedStateDirectory().getChildFile(xmlFile);
117106

118107
XmlDocument doc(file);
119108
std::unique_ptr<XmlElement> xml (doc.getDocumentElement());
@@ -139,7 +128,7 @@ void PluginInstaller::createXmlFile()
139128

140129
forEachXmlChildElement(*child, e)
141130
{
142-
File pluginPath = getPluginsLocationDirectory().getChildFile(baseStr + e->getAttributeValue(1));
131+
File pluginPath = CoreServices::getSavedStateDirectory().getChildFile(baseStr + e->getAttributeValue(1));
143132
if (!pluginPath.exists())
144133
elementsToRemove.add(e);
145134
}
@@ -341,7 +330,7 @@ void PluginInstallerComponent::comboBoxChanged(ComboBox* comboBoxThatHasChanged)
341330
void PluginInstallerComponent::run()
342331
{
343332
String fileStr = "plugins" + File::separatorString + "installedPlugins.xml";
344-
File xmlFile = getPluginsLocationDirectory().getChildFile(fileStr);
333+
File xmlFile = CoreServices::getSavedStateDirectory().getChildFile(fileStr);
345334

346335
XmlDocument doc(xmlFile);
347336
std::unique_ptr<XmlElement> xml (doc.getDocumentElement());
@@ -665,7 +654,7 @@ bool PluginListBoxComponent::loadPluginInfo(const String& pluginName)
665654

666655
// If the plugin is already installed, get installed version number
667656
String fileStr = "plugins" + File::separatorString + "installedPlugins.xml";
668-
File xmlFile = getPluginsLocationDirectory().getChildFile(fileStr);
657+
File xmlFile = CoreServices::getSavedStateDirectory().getChildFile(fileStr);
669658

670659
XmlDocument doc(xmlFile);
671660
std::unique_ptr<XmlElement> xml (doc.getDocumentElement());
@@ -1111,7 +1100,7 @@ int PluginInfoComponent::downloadPlugin(const String& plugin, const String& vers
11111100
return 0;
11121101

11131102
//Get path to plugins directory
1114-
File pluginsPath = getPluginsLocationDirectory();
1103+
File pluginsPath = CoreServices::getSavedStateDirectory();
11151104

11161105
//Construct path for downloaded zip file
11171106
String pluginFilePath = pluginsPath.getFullPathName();

0 commit comments

Comments
 (0)