File size: 1,479 Bytes
2224b8a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #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);
}
};
|