pluginbridge / Source /Plugin /Blocklist.h
RAM2118's picture
Upload Source/Plugin/Blocklist.h
2224b8a verified
Raw
History Blame Contribute Delete
1.48 kB
#pragma once
#include <juce_core/juce_core.h>
#include <set>
// Persistent blocklist — plugins that crashed are saved here.
// Path: ~/Library/PluginBridge/blocklist.txt
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
{
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);
}
};