Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:PerryWerneck
OB-Xd2
use-linux-standard-paths.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File use-linux-standard-paths.patch of Package OB-Xd2
diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 39a5f2e..3be8d5c 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -836,39 +836,90 @@ File ObxdAudioProcessor::getCurrentBankFile() const } //============================================================================== + + +/* File ObxdAudioProcessor::getDocumentFolder() const { File folder = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile("discoDSP").getChildFile("OB-Xd"); -/* if (! folder.exists()) { NativeMessageBox::showMessageBox(AlertWindow::WarningIcon, "Error", "Documents > discoDSP > OB-Xd folder not found."); } - */ if (folder.isSymbolicLink()) folder = folder.getLinkedTarget(); return folder; } +*/ + +static bool verifyDocumentFolder(File &file, const char *subdir) { + + if(file.exists()) { + if (subdir) { + file = file.getChildFile(subdir); + if (!file.exists()) { + return false; + } + } + if (file.isSymbolicLink()) + file = file.getLinkedTarget(); + return true; + } + + return false; +} + +File ObxdAudioProcessor::getDocumentFolder(const char *subdir) const { + + // First check for default path + File file = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile("discoDSP").getChildFile("OB-Xd"); + if(verifyDocumentFolder(file,subdir)) { + return file; + } + + // ... then check for common documents ... + file = File::getSpecialLocation(File::commonDocumentsDirectory).getChildFile("discoDSP").getChildFile("OB-Xd"); + if(verifyDocumentFolder(file,subdir)) { + return file; + } + + // ... and fixed system path + file = File{"/usr/share/discoDSP/OB-Xd"}; + if(verifyDocumentFolder(file,subdir)) { + return file; + } + + // ... not found, fallback to user home + + file = File::getSpecialLocation(File::userHomeDirectory).getChildFile(".discoDSP").getChildFile("OB-Xd"); + + if (subdir) + file = file.getChildFile(subdir); + + file.createDirectory(); + + return file; +} File ObxdAudioProcessor::getSkinFolder() const { - return getDocumentFolder().getChildFile("Themes"); + return getDocumentFolder("Themes"); } File ObxdAudioProcessor::getBanksFolder() const { - return getDocumentFolder().getChildFile("Banks"); + return getDocumentFolder("Banks"); } File ObxdAudioProcessor::getMidiFolder() const { - return getDocumentFolder().getChildFile("MIDI"); + return getDocumentFolder("MIDI"); } File ObxdAudioProcessor::getPresetsFolder() const { - return getDocumentFolder().getChildFile("Presets"); + return getDocumentFolder("Presets"); } File ObxdAudioProcessor::getCurrentSkinFolder() const diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 91d08f5..163bba6 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -197,7 +197,7 @@ public: const ObxdBank& getPrograms() const { return programs; } //============================================================================== - File getDocumentFolder() const; + File getDocumentFolder(const char *path = nullptr) const; File getSkinFolder() const; File getPresetsFolder() const; File getBanksFolder() const;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor