| 32 | using namespace donut::app; |
| 33 | |
| 34 | MediaFileSystem::MediaFileSystem( |
| 35 | std::shared_ptr<IFileSystem> parent, |
| 36 | const std::filesystem::path& mediaFolder) |
| 37 | { |
| 38 | // always seach media folder vfs first |
| 39 | auto mediafs = std::make_shared<RelativeFileSystem>(parent, mediaFolder); |
| 40 | |
| 41 | // open package files & add a vfs for each |
| 42 | NativeFileSystem* nativeFS = dynamic_cast<NativeFileSystem*>(parent.get()); |
| 43 | if (nativeFS) |
| 44 | { |
| 45 | std::vector<std::string> packs; |
| 46 | if (mediafs->enumerateFiles("", { ".tar" }, vfs::enumerate_to_vector(packs)) > 0) |
| 47 | { |
| 48 | // sort the packs in reverse because want to search |
| 49 | // from 'highest revision' of a pack file down (ex: pack2.pkz is |
| 50 | // searched before pack1.db) |
| 51 | std::sort(packs.rbegin(), packs.rend()); |
| 52 | |
| 53 | for (auto const& fileName : packs) |
| 54 | { |
| 55 | std::filesystem::path filePath = mediaFolder / fileName; |
| 56 | |
| 57 | bool mounted = false; |
| 58 | if (string_utils::ends_with(fileName, ".tar")) |
| 59 | { |
| 60 | if (auto packfs = std::make_shared<TarFile>(filePath); packfs->isOpen()) |
| 61 | { |
| 62 | m_FileSystems.push_back(packfs); |
| 63 | mounted = true; |
| 64 | } |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | log::warning("Cannot mount '%s': unsupported format. Skipping.", filePath.string().c_str()); |
| 69 | continue; |
| 70 | } |
| 71 | |
| 72 | if (!mounted) |
| 73 | { |
| 74 | log::warning("Failed to mount '%s' (see above for errors). Skipping.", filePath.string().c_str()); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | std::vector<std::string> MediaFileSystem::GetAvailableScenes() const |
| 82 | { |
nothing calls this directly
no test coverage detected