Skip to content

Commit f3397ad

Browse files
committed
Merge pull request #32 from cstawarz/mac_path_changes
Mac path changes
2 parents f3c8b3c + c977173 commit f3397ad

17 files changed

Lines changed: 90 additions & 69 deletions

File tree

Builds/MacOSX/Plugins/Config/Plugin.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ GCC_WARN_UNUSED_FUNCTION = YES
3838
GCC_WARN_UNUSED_VARIABLE = YES
3939
HEADER_SEARCH_PATHS = ../../../../Source/Plugins/Headers $(inherited)
4040
INSTALL_PATH = $(HOME)/Applications/open-ephys.app/Contents/PlugIns
41-
MACOSX_DEPLOYMENT_TARGET = 10.11
41+
MACOSX_DEPLOYMENT_TARGET = 10.9
4242
OTHER_LDFLAGS = $(inherited) -undefined dynamic_lookup
4343
SDKROOT = macosx
4444
SKIP_INSTALL = YES
45-
WARNING_CFLAGS = $(inherited) -Wreorder -Wno-inconsistent-missing-override
45+
WARNING_CFLAGS = $(inherited) -Wpartial-availability -Wreorder -Wno-inconsistent-missing-override
4646
WRAPPER_EXTENSION = bundle

Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,12 +2690,12 @@
26902690
"JUCE_APP_VERSION=0.4.0",
26912691
"JUCE_APP_VERSION_HEX=0x400", );
26922692
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
2693-
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "/opt/local/include", "/usr/local/include", "$(inherited)");
2693+
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)");
26942694
INFOPLIST_FILE = Info.plist;
26952695
INSTALL_PATH = "$(HOME)/Applications";
2696-
LIBRARY_SEARCH_PATHS = ("$(inherited)", "\"/opt/local/lib\"", "\"/usr/local/lib\"");
2696+
MACOSX_DEPLOYMENT_TARGET = 10.9;
26972697
MACOSX_DEPLOYMENT_TARGET_ppc = 10.4;
2698-
OTHER_CPLUSPLUSFLAGS = "-fPIC -Wno-inconsistent-missing-override";
2698+
OTHER_CPLUSPLUSFLAGS = "-fPIC -Wpartial-availability -Wno-inconsistent-missing-override";
26992699
OTHER_LDFLAGS = "-ldl -fPIC -rdynamic";
27002700
SDKROOT_ppc = macosx10.5; }; name = Debug; };
27012701
7A6F9B742B69F66DC3E29FA8 = {isa = XCBuildConfiguration; buildSettings = {
@@ -2714,12 +2714,12 @@
27142714
"JUCE_APP_VERSION_HEX=0x400", );
27152715
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
27162716
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
2717-
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "/opt/local/include", "/usr/local/include", "$(inherited)");
2717+
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)");
27182718
INFOPLIST_FILE = Info.plist;
27192719
INSTALL_PATH = "$(HOME)/Applications";
2720-
LIBRARY_SEARCH_PATHS = ("$(inherited)", "\"/opt/local/lib\"", "\"/usr/local/lib\"");
2720+
MACOSX_DEPLOYMENT_TARGET = 10.9;
27212721
MACOSX_DEPLOYMENT_TARGET_ppc = 10.4;
2722-
OTHER_CPLUSPLUSFLAGS = "-fPIC -Wno-inconsistent-missing-override";
2722+
OTHER_CPLUSPLUSFLAGS = "-fPIC -Wpartial-availability -Wno-inconsistent-missing-override";
27232723
OTHER_LDFLAGS = "-ldl -fPIC -rdynamic";
27242724
SDKROOT_ppc = macosx10.5; }; name = Release; };
27252725
C8018C9A4DA633CA60663294 = {isa = XCBuildConfiguration; buildSettings = {

Source/CoreServices.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,18 @@ const char* getApplicationResource(const char* name, int& size)
159159
{
160160
return BinaryData::getNamedResource(name, size);
161161
}
162+
163+
File getDefaultUserSaveDirectory()
164+
{
165+
#if defined(__APPLE__)
166+
File dir = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile("open-ephys");
167+
if (!dir.isDirectory()) {
168+
dir.createDirectory();
169+
}
170+
return std::move(dir);
171+
#else
172+
return File::getCurrentWorkingDirectory();
173+
#endif
174+
}
162175

163176
};

Source/CoreServices.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ PLUGIN_API int addSpikeElectrode(SpikeRecordInfo* elec);
104104
};
105105

106106
PLUGIN_API const char* getApplicationResource(const char* name, int& size);
107+
108+
/** Gets the default directory for user-initiated file saving/loading */
109+
PLUGIN_API File getDefaultUserSaveDirectory();
107110

108111
};
109112

Source/MainWindow.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
#include <stdio.h>
2626
//-----------------------------------------------------------------------
2727

28+
static inline File getSavedStateDirectory() {
29+
#if defined(__APPLE__)
30+
File dir = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile("Application Support/open-ephys");
31+
if (!dir.isDirectory()) {
32+
dir.createDirectory();
33+
}
34+
return std::move(dir);
35+
#else
36+
return File::getSpecialLocation(File::currentExecutableFile).getParentDirectory();
37+
#endif
38+
}
39+
2840
MainWindow::MainWindow()
2941
: DocumentWindow(JUCEApplication::getInstance()->getApplicationName(),
3042
Colour(Colours::black),
@@ -71,10 +83,7 @@
7183

7284
if (shouldReloadOnStartup)
7385
{
74-
File executable = File::getSpecialLocation(File::currentExecutableFile);
75-
File executableDirectory = executable.getParentDirectory();
76-
File file = executableDirectory.getChildFile("lastConfig.xml");
77-
86+
File file = getSavedStateDirectory().getChildFile("lastConfig.xml");
7887
ui->getEditorViewport()->loadState(file);
7988
}
8089

@@ -97,10 +106,7 @@ MainWindow::~MainWindow()
97106
UIComponent* ui = (UIComponent*) getContentComponent();
98107
ui->disableDataViewport();
99108

100-
File executable = File::getSpecialLocation(File::currentExecutableFile);
101-
File executableDirectory = executable.getParentDirectory();
102-
File file = executableDirectory.getChildFile("lastConfig.xml");
103-
109+
File file = getSavedStateDirectory().getChildFile("lastConfig.xml");
104110
ui->getEditorViewport()->saveState(file);
105111

106112
setMenuBar(0);
@@ -130,9 +136,7 @@ void MainWindow::saveWindowBounds()
130136
std::cout << "Saving window bounds." << std::endl;
131137
std::cout << std::endl;
132138

133-
File executable = File::getSpecialLocation(File::currentExecutableFile);
134-
File executableDirectory = executable.getParentDirectory();
135-
File file = executableDirectory.getChildFile("windowState.xml");
139+
File file = getSavedStateDirectory().getChildFile("windowState.xml");
136140

137141
XmlElement* xml = new XmlElement("MAINWINDOW");
138142

@@ -178,11 +182,7 @@ void MainWindow::loadWindowBounds()
178182
std::cout << "Loading window bounds." << std::endl;
179183
std::cout << std::endl;
180184

181-
//File file = File::getCurrentWorkingDirectory().getChildFile("windowState.xml");
182-
183-
File executable = File::getSpecialLocation(File::currentExecutableFile);
184-
File executableDirectory = executable.getParentDirectory();
185-
File file = executableDirectory.getChildFile("windowState.xml");
185+
File file = getSavedStateDirectory().getChildFile("windowState.xml");
186186

187187
XmlDocument doc(file);
188188
XmlElement* xml = doc.getDocumentElement();

Source/Plugins/ChannelMappingNode/ChannelMappingEditor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ void ChannelMappingEditor::buttonEvent(Button* button)
553553
if (!acquisitionIsActive)
554554
{
555555
FileChooser fc("Choose the file name...",
556-
File::getCurrentWorkingDirectory(),
556+
CoreServices::getDefaultUserSaveDirectory(),
557557
"*",
558558
true);
559559

@@ -576,7 +576,7 @@ void ChannelMappingEditor::buttonEvent(Button* button)
576576
if (!acquisitionIsActive)
577577
{
578578
FileChooser fc("Choose a file to load...",
579-
File::getCurrentWorkingDirectory(),
579+
CoreServices::getDefaultUserSaveDirectory(),
580580
"*",
581581
true);
582582

Source/Plugins/KWIKFormat/RecordEngine/HDF5Recording.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define CHANNEL_TIMESTAMP_MIN_WRITE 32
2828
#define TIMESTAMP_EACH_NSAMPLES 1024
2929

30-
HDF5Recording::HDF5Recording() : processorIndex(-1), hasAcquired(false), bufferSize(MAX_BUFFER_SIZE)
30+
HDF5Recording::HDF5Recording() : processorIndex(-1), bufferSize(MAX_BUFFER_SIZE), hasAcquired(false)
3131
{
3232
//timestamp = 0;
3333
scaledBuffer.malloc(MAX_BUFFER_SIZE);

Source/Processors/Editors/ChannelSelector.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ void ChannelSelector::shiftChannelsVertical(float amount)
215215

216216
void ChannelSelector::refreshButtonBoundaries()
217217
{
218-
int column = 0;
219-
int row = 0;
220-
int nColumns;
218+
//int column = 0;
219+
//int row = 0;
220+
//int nColumns;
221221

222-
const int numButtons = parameterButtonsManager.getNumButtons();
222+
//const int numButtons = parameterButtonsManager.getNumButtons();
223223
const int columnWidth = getDesiredWidth() / (numColumnsGreaterThan100 + 1) + 1;
224224
const int rowHeight = 14;
225225

Source/Processors/FileReader/FileReaderEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ FileReaderEditor::FileReaderEditor (GenericProcessor* parentNode, bool useDefaul
3636
, recTotalTime (0)
3737
, m_isFileDragAndDropActive (false)
3838
{
39-
lastFilePath = File::getCurrentWorkingDirectory();
39+
lastFilePath = CoreServices::getDefaultUserSaveDirectory();
4040

4141
fileButton = new UtilityButton ("F:", Font ("Small Text", 13, Font::plain));
4242
fileButton->addListener (this);

Source/Processors/PluginManager/PluginManager.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,35 @@ PluginManager::~PluginManager()
8181

8282
void PluginManager::loadAllPlugins()
8383
{
84-
Array<File> foundDLLs;
84+
Array<File> paths;
85+
86+
#ifdef __APPLE__
87+
paths.add(File::getSpecialLocation(File::currentApplicationFile).getChildFile("Contents/PlugIns"));
88+
paths.add(File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile("Application Support/open-ephys/PlugIns"));
89+
#else
90+
paths.add(File::getSpecialLocation(File::currentApplicationFile).getParentDirectory().getChildFile("plugins"));
91+
#endif
92+
93+
for (auto &pluginPath : paths) {
94+
if (!pluginPath.isDirectory()) {
95+
std::cout << "Plugin path not found: " << pluginPath.getFullPathName() << std::endl;
96+
} else {
97+
loadPlugins(pluginPath);
98+
}
99+
}
100+
}
85101

102+
void PluginManager::loadPlugins(const File &pluginPath) {
103+
Array<File> foundDLLs;
104+
86105
#ifdef WIN32
87-
File pluginPath = File::getSpecialLocation(File::currentApplicationFile).getParentDirectory().getChildFile("plugins");
88-
String pluginExt("*.dll");
106+
String pluginExt("*.dll");
89107
#elif defined(__APPLE__)
90-
File pluginPath = File::getSpecialLocation(File::currentApplicationFile).getChildFile("Contents/PlugIns");
91108
String pluginExt("*.bundle");
92109
#else
93-
File pluginPath = File::getSpecialLocation(File::currentApplicationFile).getParentDirectory().getChildFile("plugins");
94-
String pluginExt("*.so");
110+
String pluginExt("*.so");
95111
#endif
96-
97-
98-
if (!pluginPath.isDirectory())
99-
{
100-
std::cout << "Plugin path not found" << std::endl;
101-
return;
102-
}
103-
112+
104113
#ifdef __APPLE__
105114
pluginPath.findChildFiles(foundDLLs, File::findDirectories, false, pluginExt);
106115
#else

0 commit comments

Comments
 (0)