gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 7bd8ba3470109290e194aebab9b43369bc760d28
parent 649fedf93dce572d46b66623c30049e1feb82bb2
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Fri, 29 Nov 2024 23:21:33 +0100

do not log file access errors if not really needed

Diffstat:
Msource/jucePluginLib/patchdb/db.cpp | 29++++++++++++++++-------------
Msource/jucePluginLib/patchdb/db.h | 2++
2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/source/jucePluginLib/patchdb/db.cpp b/source/jucePluginLib/patchdb/db.cpp @@ -253,10 +253,8 @@ namespace pluginLib::patchDB saveJson(); - if(oldFile.existsAsFile()) - (void)oldFile.deleteFile(); - if(oldJsonFile.existsAsFile()) - (void)oldJsonFile.deleteFile(); + deleteFile(oldFile); + deleteFile(oldJsonFile); }); } @@ -1518,6 +1516,17 @@ namespace pluginLib::patchDB return success; } + bool DB::deleteFile(const juce::File& _file) + { + if (!_file.existsAsFile()) + return true; + if (_file.deleteFile()) + return true; + + pushError("Failed to delete file:\n" + _file.getFullPathName().toStdString()); + return false; + } + bool DB::saveJson() { m_cacheDirty = true; @@ -1527,7 +1536,7 @@ namespace pluginLib::patchDB jsonFile.createDirectory(); - cacheFile.deleteFile(); + deleteFile(cacheFile); if (!jsonFile.hasWriteAccess()) { @@ -1661,12 +1670,6 @@ namespace pluginLib::patchDB if(!juce::File::isAbsolutePath(filename.getFullPathName())) filename = m_settingsDir.getChildFile(filename.getFullPathName()); - if(!filename.hasWriteAccess()) - { - pushError("No write access to file:\n" + filename.getFullPathName().toStdString()); - return false; - } - if(_ds->patches.empty()) { filename.deleteFile(); @@ -1729,7 +1732,7 @@ namespace pluginLib::patchDB pushError("Failed to copy\n" + tempFile.getFullPathName().toStdString() + "\nto\n" + _target.getFullPathName().toStdString()); return false; } - tempFile.deleteFile(); + deleteFile(tempFile); return true; } @@ -1769,7 +1772,7 @@ namespace pluginLib::patchDB if(patches.empty()) { - file.deleteFile(); + deleteFile(file); } else { diff --git a/source/jucePluginLib/patchdb/db.h b/source/jucePluginLib/patchdb/db.h @@ -137,6 +137,8 @@ namespace pluginLib::patchDB bool loadPatchModifications(const DataSourceNodePtr& _ds, const std::vector<PatchPtr>& _patches); static bool loadPatchModifications(std::map<PatchKey, PatchModificationsPtr>& _patchModifications, const juce::var& _parentNode, const DataSourceNodePtr& _dataSource = nullptr); + bool deleteFile(const juce::File& _file); + bool saveJson(); bool saveJson(const DataSourceNodePtr& _ds); bool saveJson(const juce::File& _target, juce::DynamicObject* _src);