MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / DirectoryChanged

Method DirectoryChanged

plugins/base/macro-condition-folder.cpp:123–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void MacroConditionFolder::DirectoryChanged(const QString &path)
124{
125 std::lock_guard<std::mutex> lock(_mutex);
126 if (MacroIsPaused(GetMacro())) {
127 return;
128 }
129
130 auto currentFiles = getFilesInDir(path);
131 auto currentDirs = getDirsInDir(path);
132
133 if (currentFiles.count() > _currentFiles.count()) {
134 _newFiles += currentFiles - _currentFiles;
135 } else {
136 _removedFiles += _currentFiles - currentFiles;
137 }
138
139 if (currentDirs.count() > _currentDirs.count()) {
140 _newDirs += currentDirs - _currentDirs;
141 } else {
142 _removedDirs += _currentDirs - currentDirs;
143 }
144
145 if (_enableFilter) {
146 reduceSetToPatternMatch(_newFiles, _regex, _filter);
147 reduceSetToPatternMatch(_removedFiles, _regex, _filter);
148 reduceSetToPatternMatch(_newDirs, _regex, _filter);
149 reduceSetToPatternMatch(_removedDirs, _regex, _filter);
150 }
151
152 switch (_condition) {
153 case Condition::ANY:
154 _matched = _matched || _newFiles.count() > 0 ||
155 _removedFiles.count() > 0 || _newDirs.count() > 0 ||
156 _removedDirs.count() > 0;
157 break;
158 case Condition::FILE_ADD:
159 _matched = _newFiles.count() > 0;
160 break;
161 case Condition::FILE_REMOVE:
162 _matched = _removedFiles.count() > 0;
163 break;
164 case Condition::FOLDER_ADD:
165 _matched = _newDirs.count() > 0;
166 break;
167 case Condition::FOLDER_REMOVE:
168 _matched = _removedDirs.count() > 0;
169 break;
170 default:
171 break;
172 }
173
174 for (const auto &newFile : _newFiles) {
175 _watcher->addPath(path + "/" + newFile);
176 }
177
178 _currentFiles = currentFiles;
179 _currentDirs = currentDirs;
180}

Callers

nothing calls this directly

Calls 6

MacroIsPausedFunction · 0.85
GetMacroFunction · 0.85
getFilesInDirFunction · 0.85
getDirsInDirFunction · 0.85
reduceSetToPatternMatchFunction · 0.85
countMethod · 0.80

Tested by

no test coverage detected