Upload Source/Plugin/Blocklist.h
Browse files- Source/Plugin/Blocklist.h +64 -0
Source/Plugin/Blocklist.h
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
#include <juce_core/juce_core.h>
|
| 4 |
+
#include <set>
|
| 5 |
+
|
| 6 |
+
// Persistent blocklist — plugins that crashed are saved here.
|
| 7 |
+
// Path: ~/Library/PluginBridge/blocklist.txt
|
| 8 |
+
|
| 9 |
+
class Blocklist
|
| 10 |
+
{
|
| 11 |
+
public:
|
| 12 |
+
Blocklist() { load(); }
|
| 13 |
+
|
| 14 |
+
bool isBlocked(const juce::String& path) const
|
| 15 |
+
{
|
| 16 |
+
return blockedPaths.count(path.toStdString()) > 0;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
void addBlocked(const juce::String& path)
|
| 20 |
+
{
|
| 21 |
+
blockedPaths.insert(path.toStdString());
|
| 22 |
+
save();
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
void clear()
|
| 26 |
+
{
|
| 27 |
+
blockedPaths.clear();
|
| 28 |
+
save();
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
private:
|
| 32 |
+
std::set<std::string> blockedPaths;
|
| 33 |
+
|
| 34 |
+
juce::File getBlocklistFile() const
|
| 35 |
+
{
|
| 36 |
+
auto dir = juce::File::getSpecialLocation(juce::File::userApplicationDataDirectory)
|
| 37 |
+
.getChildFile("PluginBridge");
|
| 38 |
+
dir.createDirectory();
|
| 39 |
+
return dir.getChildFile("blocklist.txt");
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
void load()
|
| 43 |
+
{
|
| 44 |
+
auto file = getBlocklistFile();
|
| 45 |
+
if (!file.existsAsFile()) return;
|
| 46 |
+
juce::StringArray lines;
|
| 47 |
+
file.readLines(lines);
|
| 48 |
+
for (auto& line : lines)
|
| 49 |
+
{
|
| 50 |
+
auto trimmed = line.trim();
|
| 51 |
+
if (trimmed.isNotEmpty())
|
| 52 |
+
blockedPaths.insert(trimmed.toStdString());
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
void save()
|
| 57 |
+
{
|
| 58 |
+
auto file = getBlocklistFile();
|
| 59 |
+
juce::String content;
|
| 60 |
+
for (auto& path : blockedPaths)
|
| 61 |
+
content += juce::String(path) + "\n";
|
| 62 |
+
file.replaceWithText(content);
|
| 63 |
+
}
|
| 64 |
+
};
|