deconstructed_rom_directory.h 1.6 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/program_metadata.h"
  8. #include "core/hle/kernel/kernel.h"
  9. #include "core/loader/loader.h"
  10. namespace Loader {
  11. /**
  12. * This class loads a "deconstructed ROM directory", which are the typical format we see for Switch
  13. * game dumps. The path should be a "main" NSO, which must be in a directory that contains the other
  14. * standard ExeFS NSOs (e.g. rtld, sdk, etc.). It will automatically find and load these.
  15. * Furthermore, it will look for the first .romfs file (optionally) and use this for the RomFS.
  16. */
  17. class AppLoader_DeconstructedRomDirectory final : public AppLoader {
  18. public:
  19. AppLoader_DeconstructedRomDirectory(FileUtil::IOFile&& file, std::string filepath);
  20. /**
  21. * Returns the type of the file
  22. * @param file FileUtil::IOFile open file
  23. * @param filepath Path of the file that we are opening.
  24. * @return FileType found, or FileType::Error if this loader doesn't know it
  25. */
  26. static FileType IdentifyType(FileUtil::IOFile& file, const std::string& filepath);
  27. FileType GetFileType() override {
  28. return IdentifyType(file, filepath);
  29. }
  30. ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
  31. ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
  32. u64& size) override;
  33. private:
  34. std::string filepath_romfs;
  35. std::string filepath;
  36. FileSys::ProgramMetadata metadata;
  37. };
  38. } // namespace Loader