MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / MediaFileSystem

Method MediaFileSystem

src/app/MediaFileSystem.cpp:34–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32using namespace donut::app;
33
34MediaFileSystem::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
81std::vector<std::string> MediaFileSystem::GetAvailableScenes() const
82{

Callers

nothing calls this directly

Calls 9

enumerate_to_vectorFunction · 0.85
ends_withFunction · 0.85
warningFunction · 0.85
getMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
isOpenMethod · 0.80
push_backMethod · 0.80
enumerateFilesMethod · 0.45

Tested by

no test coverage detected