| 35 | } |
| 36 | |
| 37 | std::vector<Path> InMemoryDiskCache::list(const Path& path) const { |
| 38 | auto absolutePath = toAbsolutePath(path); |
| 39 | std::vector<Path> output; |
| 40 | FlatSet<StringBox> seenEntries; |
| 41 | std::lock_guard<Mutex> guard(_cache->mutex); |
| 42 | |
| 43 | auto& entries = _cache->entries; |
| 44 | |
| 45 | for (const auto& it : entries) { |
| 46 | Path existingPath(it.first.toStringView()); |
| 47 | |
| 48 | if (existingPath.getComponents().size() > absolutePath.getComponents().size() && |
| 49 | existingPath.startsWith(absolutePath)) { |
| 50 | auto newPath = absolutePath.appending(existingPath.getComponents()[absolutePath.getComponents().size()]); |
| 51 | auto inserted = seenEntries.insert(newPath.toStringBox()); |
| 52 | if (inserted.second) { |
| 53 | output.emplace_back(std::move(newPath)); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return output; |
| 59 | } |
| 60 | |
| 61 | Path InMemoryDiskCache::toAbsolutePath(const Path& relativePath) const { |
| 62 | auto newPath = !relativePath.isAbsolute() ? _rootPath.appending(relativePath) : relativePath; |
no test coverage detected