| 31 | } |
| 32 | |
| 33 | std::vector<std::string> FileFinder::FindFiles() { |
| 34 | std::vector<std::string> files; |
| 35 | |
| 36 | CollectFile(_root, files); |
| 37 | |
| 38 | if (_ignorePatterns.empty()) { |
| 39 | return files; |
| 40 | } |
| 41 | |
| 42 | std::vector<std::string> resultFiles; |
| 43 | auto rootPath = _root.string(); |
| 44 | for (auto &originFile: files) { |
| 45 | auto matchFilePath = string_util::GetFileRelativePath(rootPath, originFile); |
| 46 | if (!matchFilePath.empty()) { |
| 47 | for (auto &pattern: _ignorePatterns) { |
| 48 | if (string_util::FileWildcardMatch(matchFilePath, pattern)) { |
| 49 | goto nextFile; |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | resultFiles.push_back(originFile); |
| 54 | nextFile:;//ignore |
| 55 | } |
| 56 | return resultFiles; |
| 57 | } |
| 58 | |
| 59 | void FileFinder::CollectFile(std::filesystem::path directoryPath, std::vector<std::string> &paths) { |
| 60 | if (!std::filesystem::exists(directoryPath)) { |
no test coverage detected