RAM2118 commited on
Commit
377833b
·
verified ·
1 Parent(s): 01a8444

Upload Source/Plugin/Blocklist.h

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