bis_factory.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <fmt/format.h>
  5. #include "core/file_sys/bis_factory.h"
  6. #include "core/file_sys/registered_cache.h"
  7. namespace FileSys {
  8. BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_, VirtualDir dump_root_)
  9. : nand_root(std::move(nand_root_)), load_root(std::move(load_root_)),
  10. dump_root(std::move(dump_root_)),
  11. sysnand_cache(std::make_unique<RegisteredCache>(
  12. GetOrCreateDirectoryRelative(nand_root, "/system/Contents/registered"))),
  13. usrnand_cache(std::make_unique<RegisteredCache>(
  14. GetOrCreateDirectoryRelative(nand_root, "/user/Contents/registered"))) {}
  15. BISFactory::~BISFactory() = default;
  16. RegisteredCache* BISFactory::GetSystemNANDContents() const {
  17. return sysnand_cache.get();
  18. }
  19. RegisteredCache* BISFactory::GetUserNANDContents() const {
  20. return usrnand_cache.get();
  21. }
  22. VirtualDir BISFactory::GetModificationLoadRoot(u64 title_id) const {
  23. // LayeredFS doesn't work on updates and title id-less homebrew
  24. if (title_id == 0 || (title_id & 0x800) > 0)
  25. return nullptr;
  26. return GetOrCreateDirectoryRelative(load_root, fmt::format("/{:016X}", title_id));
  27. }
  28. VirtualDir BISFactory::GetModificationDumpRoot(u64 title_id) const {
  29. if (title_id == 0)
  30. return nullptr;
  31. return GetOrCreateDirectoryRelative(dump_root, fmt::format("/{:016X}", title_id));
  32. }
  33. } // namespace FileSys