commit 3ac99ea1d5e7c22b2d8b45ee6ffa1637300f6508
parent 5f4ab89a0b3800df9b4973cc6d3a2b9d77998496
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sat, 2 Nov 2024 17:43:45 +0100
migrate config file to new location in new data root
Diffstat:
4 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/source/jucePluginEditorLib/pluginProcessor.cpp b/source/jucePluginEditorLib/pluginProcessor.cpp
@@ -24,7 +24,7 @@ namespace jucePluginEditorLib
Processor::Processor(const BusesProperties& _busesProperties, const juce::PropertiesFile::Options& _configOptions, const pluginLib::Processor::Properties& _properties)
: pluginLib::Processor(_busesProperties, _properties)
, m_configOptions(_configOptions)
- , m_config(_configOptions)
+ , m_config(initConfigFile(_configOptions), _configOptions)
{
#ifdef ZYNTHIAN
Logging::setLogFunc(&noLoggingFunc);
@@ -140,4 +140,22 @@ namespace jucePluginEditorLib
getController().loadChunkData(_cr);
}
+
+ juce::File Processor::initConfigFile(const juce::PropertiesFile::Options& _o) const
+ {
+ // copy from old location to new if still exists
+ juce::File oldFile(_o.getDefaultFile());
+
+ juce::File newFile(getConfigFile(false));
+
+ if(oldFile.existsAsFile())
+ {
+ newFile.createDirectory();
+ if(!oldFile.copyFileTo(newFile))
+ return oldFile;
+ oldFile.deleteFile();
+ return newFile;
+ }
+ return newFile;
+ }
}
diff --git a/source/jucePluginEditorLib/pluginProcessor.h b/source/jucePluginEditorLib/pluginProcessor.h
@@ -28,6 +28,8 @@ namespace jucePluginEditorLib
void loadChunkData(baseLib::ChunkReader& _cr) override;
private:
+ juce::File initConfigFile(const juce::PropertiesFile::Options& _o) const;
+
std::unique_ptr<PluginEditorState> m_editorState;
juce::PropertiesFile::Options m_configOptions;
diff --git a/source/jucePluginLib/processor.cpp b/source/jucePluginLib/processor.cpp
@@ -338,18 +338,33 @@ namespace pluginLib
return {};
}
+ std::string Processor::getDataFolder(const bool _useFxFolder) const
+ {
+ return Tools::getPublicDataFolder(getProperties().vendor, getProductName(_useFxFolder));
+ }
+
std::string Processor::getPublicRomFolder() const
{
- return getDataFolder() + "roms/";
+ return synthLib::validatePath(getDataFolder() + "roms/");
}
- std::string Processor::getDataFolder(const bool _useFxFolder) const
+ std::string Processor::getConfigFolder(const bool _useFxFolder) const
+ {
+ return synthLib::validatePath(getDataFolder(_useFxFolder) + "config/");
+ }
+
+ std::string Processor::getConfigFile(const bool _useFxFolder) const
+ {
+ return getConfigFolder(_useFxFolder) + getProductName(_useFxFolder) + ".xml";
+ }
+
+ std::string Processor::getProductName(const bool _useFxName) const
{
const auto& p = getProperties();
auto name = p.name;
- if(!_useFxFolder && p.isSynth && name.substr(name.size()-2, 2) == "FX")
- name = name.substr(name.size() - 2);
- return Tools::getPublicDataFolder(p.vendor, name);
+ if(!_useFxName && p.isSynth && name.substr(name.size()-2, 2) == "FX")
+ return name.substr(name.size() - 2);
+ return name;
}
void Processor::destroyController()
diff --git a/source/jucePluginLib/processor.h b/source/jucePluginLib/processor.h
@@ -122,8 +122,11 @@ namespace pluginLib
std::optional<std::pair<const char*, uint32_t>> findResource(const std::string& _filename) const;
- std::string getPublicRomFolder() const;
std::string getDataFolder(bool _useFxFolder = false) const;
+ std::string getPublicRomFolder() const;
+ std::string getConfigFolder(bool _useFxFolder = false) const;
+ std::string getConfigFile(bool _useFxFolder = false) const;
+ std::string getProductName(bool _useFxName = false) const;
protected:
void destroyController();