pluginbridge / Source /Plugin /Blocklist.h
RAM2118's picture
fix: Blocklist path corrected to ~/Library/PluginBridge/ (where JUCE actually writes)"
b1feaca verified
Raw History Blame
1.63 kB
#pragma once
#include <juce_core/juce_core.h>
#include <set>
// Persistent blocklist — stores plugin paths that crashed on load.
// Saved to ~/Library/PluginBridge/blocklist.txt
// (JUCE's userApplicationDataDirectory on macOS = ~/Library/)
class Blocklist
{
public:
Blocklist()
{
load();
}
bool isBlocked(const juce::String& path) const
{
return blockedPaths.count(path.toStdString()) > 0;
}
void addBlocked(const juce::String& path)
{
blockedPaths.insert(path.toStdString());
save();
}
void clear()
{
blockedPaths.clear();
save();
}
private:
std::set<std::string> blockedPaths;
juce::File getBlocklistFile() const
{
// userApplicationDataDirectory on macOS = ~/Library/
auto dir = juce::File::getSpecialLocation(juce::File::userApplicationDataDirectory)
.getChildFile("PluginBridge");
dir.createDirectory();
return dir.getChildFile("blocklist.txt");
}
void load()
{
auto file = getBlocklistFile();
if (!file.existsAsFile()) return;
juce::StringArray lines;
file.readLines(lines);
for (auto& line : lines)
{
auto trimmed = line.trim();
if (trimmed.isNotEmpty())
blockedPaths.insert(trimmed.toStdString());
}
}
void save()
{
auto file = getBlocklistFile();
juce::String content;
for (auto& path : blockedPaths)
content += juce::String(path) + "\n";
file.replaceWithText(content);
}
};