| // 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); | |
| } | |
| }; | |