MCPcopy Create free account
hub / github.com/Axosoft/nsfw / updateExcludedPaths

Method updateExcludedPaths

src/linux/InotifyTree.cpp:199–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void InotifyTree::updateExcludedPaths(const std::vector<std::string> &excludedPaths) {
200 std::vector<std::string> addedExcludedPaths;
201 std::vector<std::string> removedExcludedPaths;
202
203 std::unordered_set<std::string> currentExcludedPaths(mExcludedPaths.begin(), mExcludedPaths.end());
204 std::unordered_set<std::string> newExcludedPaths;
205
206 for (auto excludedPath : excludedPaths) {
207 newExcludedPaths.insert(excludedPath);
208 if (currentExcludedPaths.find(excludedPath) == currentExcludedPaths.end()) {
209 addedExcludedPaths.push_back(excludedPath);
210 }
211 }
212
213 for (auto excludedPath : mExcludedPaths) {
214 if (newExcludedPaths.find(excludedPath) == newExcludedPaths.end()) {
215 removedExcludedPaths.push_back(excludedPath);
216 }
217 }
218
219 mExcludedPaths = excludedPaths;
220
221 for (auto excludedPath : removedExcludedPaths) {
222 auto path = getParentPath(excludedPath);
223 InotifyNode *node = findNodeByPath(path);
224 if (node) {
225 std::string base_directory = excludedPath.substr(excludedPath.find_last_of("/") + 1);
226 node->addChild(base_directory, NULL);
227 }
228 }
229
230 for (auto excludedPath : addedExcludedPaths) {
231 auto path = getParentPath(excludedPath);
232 InotifyNode *node = findNodeByPath(path);
233 if (node) {
234 std::string base_directory = excludedPath.substr(excludedPath.find_last_of("/") + 1);
235 node->removeChild(base_directory);
236 }
237 }
238
239}
240
241/**
242 * InotifyNode ---------------------------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

addChildMethod · 0.80
removeChildMethod · 0.80

Tested by

no test coverage detected