submission_package.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include <memory>
  7. #include <vector>
  8. #include "common/common_types.h"
  9. #include "core/file_sys/vfs.h"
  10. namespace Loader {
  11. enum class ResultStatus : u16;
  12. }
  13. namespace FileSys {
  14. class NCA;
  15. class PartitionFilesystem;
  16. enum class ContentRecordType : u8;
  17. class NSP : public ReadOnlyVfsDirectory {
  18. public:
  19. explicit NSP(VirtualFile file);
  20. ~NSP() override;
  21. Loader::ResultStatus GetStatus() const;
  22. Loader::ResultStatus GetProgramStatus(u64 title_id) const;
  23. // Should only be used when one title id can be assured.
  24. u64 GetFirstTitleID() const;
  25. u64 GetProgramTitleID() const;
  26. std::vector<u64> GetTitleIDs() const;
  27. bool IsExtractedType() const;
  28. // Common (Can be safely called on both types)
  29. VirtualFile GetRomFS() const;
  30. VirtualDir GetExeFS() const;
  31. // Type 0 Only (Collection of NCAs + Certificate + Ticket + Meta XML)
  32. std::vector<std::shared_ptr<NCA>> GetNCAsCollapsed() const;
  33. std::multimap<u64, std::shared_ptr<NCA>> GetNCAsByTitleID() const;
  34. std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> GetNCAs() const;
  35. std::shared_ptr<NCA> GetNCA(u64 title_id, ContentRecordType type) const;
  36. VirtualFile GetNCAFile(u64 title_id, ContentRecordType type) const;
  37. std::vector<Core::Crypto::Key128> GetTitlekey() const;
  38. std::vector<VirtualFile> GetFiles() const override;
  39. std::vector<VirtualDir> GetSubdirectories() const override;
  40. std::string GetName() const override;
  41. VirtualDir GetParentDirectory() const override;
  42. private:
  43. void InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files);
  44. void ReadNCAs(const std::vector<VirtualFile>& files);
  45. VirtualFile file;
  46. bool extracted = false;
  47. Loader::ResultStatus status;
  48. std::map<u64, Loader::ResultStatus> program_status;
  49. std::shared_ptr<PartitionFilesystem> pfs;
  50. // Map title id -> {map type -> NCA}
  51. std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> ncas;
  52. std::vector<VirtualFile> ticket_files;
  53. Core::Crypto::KeyManager keys;
  54. VirtualFile romfs;
  55. VirtualDir exefs;
  56. };
  57. } // namespace FileSys