| 127 | } |
| 128 | |
| 129 | int MediaFileSystem::enumerateFiles(const std::filesystem::path& path, const std::vector<std::string>& extensions, enumerate_callback_t callback, bool allowDuplicates) |
| 130 | { |
| 131 | int numRawResults = 0; |
| 132 | std::unordered_set<std::string> resultSet; |
| 133 | for (const auto& fs : m_FileSystems) |
| 134 | { |
| 135 | if (allowDuplicates) |
| 136 | { |
| 137 | int result = fs->enumerateFiles(path, extensions, callback, true); |
| 138 | if (result >= 0) |
| 139 | numRawResults += result; |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | fs->enumerateFiles(path, extensions, |
| 144 | [&resultSet](std::string_view name) |
| 145 | { |
| 146 | resultSet.insert(std::string(name)); |
| 147 | }, true); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | if (!allowDuplicates) |
| 152 | { |
| 153 | // pass the deduplicated names to the caller |
| 154 | std::for_each(resultSet.begin(), resultSet.end(), callback); |
| 155 | return int(resultSet.size()); |
| 156 | } |
| 157 | |
| 158 | return numRawResults; |
| 159 | } |
| 160 | |
| 161 | int MediaFileSystem::enumerateDirectories(const std::filesystem::path& path, enumerate_callback_t callback, bool allowDuplicates) |
| 162 | { |
no test coverage detected