| 159 | } |
| 160 | |
| 161 | int MediaFileSystem::enumerateDirectories(const std::filesystem::path& path, enumerate_callback_t callback, bool allowDuplicates) |
| 162 | { |
| 163 | int numRawResults = 0; |
| 164 | std::unordered_set<std::string> resultSet; |
| 165 | for (const auto& fs : m_FileSystems) |
| 166 | { |
| 167 | if (allowDuplicates) |
| 168 | { |
| 169 | int result = fs->enumerateDirectories(path, callback, true); |
| 170 | if (result >= 0) |
| 171 | numRawResults += result; |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | fs->enumerateDirectories(path, |
| 176 | [&resultSet](std::string_view name) |
| 177 | { |
| 178 | resultSet.insert(std::string(name)); |
| 179 | }, true); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | if (!allowDuplicates) |
| 184 | { |
| 185 | // pass the deduplicated names to the caller |
| 186 | std::for_each(resultSet.begin(), resultSet.end(), callback); |
| 187 | return int(resultSet.size()); |
| 188 | } |
| 189 | |
| 190 | return numRawResults; |
| 191 | } |
no test coverage detected