romfs_factory.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include "common/common_types.h"
  6. #include "core/file_sys/vfs_types.h"
  7. #include "core/hle/result.h"
  8. namespace Loader {
  9. class AppLoader;
  10. } // namespace Loader
  11. namespace Service::FileSystem {
  12. class FileSystemController;
  13. }
  14. namespace FileSys {
  15. class ContentProvider;
  16. class NCA;
  17. enum class ContentRecordType : u8;
  18. enum class StorageId : u8 {
  19. None = 0,
  20. Host = 1,
  21. GameCard = 2,
  22. NandSystem = 3,
  23. NandUser = 4,
  24. SdCard = 5,
  25. };
  26. /// File system interface to the RomFS archive
  27. class RomFSFactory {
  28. public:
  29. explicit RomFSFactory(Loader::AppLoader& app_loader, ContentProvider& provider,
  30. Service::FileSystem::FileSystemController& controller);
  31. ~RomFSFactory();
  32. void SetPackedUpdate(VirtualFile update_raw_file);
  33. [[nodiscard]] VirtualFile OpenCurrentProcess(u64 current_process_title_id) const;
  34. [[nodiscard]] VirtualFile OpenPatchedRomFS(u64 title_id, ContentRecordType type) const;
  35. [[nodiscard]] VirtualFile OpenPatchedRomFSWithProgramIndex(u64 title_id, u8 program_index,
  36. ContentRecordType type) const;
  37. [[nodiscard]] VirtualFile Open(u64 title_id, StorageId storage, ContentRecordType type) const;
  38. private:
  39. [[nodiscard]] std::shared_ptr<NCA> GetEntry(u64 title_id, StorageId storage,
  40. ContentRecordType type) const;
  41. VirtualFile file;
  42. VirtualFile update_raw;
  43. bool updatable;
  44. u64 ivfc_offset;
  45. ContentProvider& content_provider;
  46. Service::FileSystem::FileSystemController& filesystem_controller;
  47. };
  48. } // namespace FileSys