nca.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 <string>
  6. #include "common/common_types.h"
  7. #include "core/file_sys/content_archive.h"
  8. #include "core/file_sys/program_metadata.h"
  9. #include "core/hle/kernel/object.h"
  10. #include "core/loader/loader.h"
  11. #include "deconstructed_rom_directory.h"
  12. namespace Loader {
  13. /// Loads an NCA file
  14. class AppLoader_NCA final : public AppLoader {
  15. public:
  16. explicit AppLoader_NCA(FileSys::VirtualFile file);
  17. /**
  18. * Returns the type of the file
  19. * @param file std::shared_ptr<VfsFile> open file
  20. * @return FileType found, or FileType::Error if this loader doesn't know it
  21. */
  22. static FileType IdentifyType(const FileSys::VirtualFile& file);
  23. FileType GetFileType() override {
  24. return IdentifyType(file);
  25. }
  26. ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
  27. ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
  28. ResultStatus ReadProgramId(u64& out_program_id) override;
  29. ~AppLoader_NCA();
  30. private:
  31. FileSys::ProgramMetadata metadata;
  32. FileSys::NCAHeader header;
  33. std::unique_ptr<FileSys::NCA> nca;
  34. std::unique_ptr<AppLoader_DeconstructedRomDirectory> directory_loader;
  35. };
  36. } // namespace Loader