2022-04-23 04:59:50 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-10-05 23:30:08 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-19 20:45:55 -04:00
|
|
|
#include <memory>
|
2017-10-05 23:30:08 -04:00
|
|
|
#include <string>
|
2018-10-23 18:35:20 -04:00
|
|
|
#include <vector>
|
2017-10-05 23:30:08 -04:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "core/loader/loader.h"
|
|
|
|
|
2020-09-16 08:19:25 -04:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2018-07-23 17:27:50 -04:00
|
|
|
namespace FileSys {
|
|
|
|
class NACP;
|
|
|
|
}
|
|
|
|
|
2018-12-02 22:13:50 -05:00
|
|
|
namespace Kernel {
|
2021-04-24 01:04:28 -04:00
|
|
|
class KProcess;
|
2018-12-02 22:13:50 -05:00
|
|
|
}
|
|
|
|
|
2017-10-05 23:30:08 -04:00
|
|
|
namespace Loader {
|
|
|
|
|
|
|
|
/// Loads an NRO file
|
2019-03-19 20:45:55 -04:00
|
|
|
class AppLoader_NRO final : public AppLoader {
|
2017-10-05 23:30:08 -04:00
|
|
|
public:
|
2021-04-27 12:05:34 -04:00
|
|
|
explicit AppLoader_NRO(FileSys::VirtualFile file_);
|
2018-07-23 17:27:50 -04:00
|
|
|
~AppLoader_NRO() override;
|
2017-10-05 23:30:08 -04:00
|
|
|
|
|
|
|
/**
|
2021-04-27 12:05:34 -04:00
|
|
|
* Identifies whether or not the given file is an NRO file.
|
|
|
|
*
|
|
|
|
* @param nro_file The file to identify.
|
|
|
|
*
|
|
|
|
* @return FileType::NRO, or FileType::Error if the file is not an NRO file.
|
2017-10-05 23:30:08 -04:00
|
|
|
*/
|
2021-04-27 12:05:34 -04:00
|
|
|
static FileType IdentifyType(const FileSys::VirtualFile& nro_file);
|
2017-10-05 23:30:08 -04:00
|
|
|
|
2018-12-05 17:42:41 -05:00
|
|
|
FileType GetFileType() const override {
|
2018-07-18 21:07:11 -04:00
|
|
|
return IdentifyType(file);
|
2017-10-05 23:30:08 -04:00
|
|
|
}
|
|
|
|
|
2021-04-24 01:04:28 -04:00
|
|
|
LoadResult Load(Kernel::KProcess& process, Core::System& system) override;
|
2017-10-05 23:30:08 -04:00
|
|
|
|
2018-07-23 12:33:24 -04:00
|
|
|
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
|
|
|
ResultStatus ReadProgramId(u64& out_program_id) override;
|
|
|
|
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
|
|
|
ResultStatus ReadTitle(std::string& title) override;
|
2019-09-07 17:40:21 -04:00
|
|
|
ResultStatus ReadControlData(FileSys::NACP& control) override;
|
2018-08-26 10:53:31 -04:00
|
|
|
bool IsRomFSUpdatable() const override;
|
2018-07-23 12:33:24 -04:00
|
|
|
|
2017-10-05 23:30:08 -04:00
|
|
|
private:
|
2021-04-24 01:04:28 -04:00
|
|
|
bool LoadNro(Kernel::KProcess& process, const FileSys::VfsFile& nro_file);
|
2018-07-23 12:33:24 -04:00
|
|
|
|
|
|
|
std::vector<u8> icon_data;
|
|
|
|
std::unique_ptr<FileSys::NACP> nacp;
|
|
|
|
FileSys::VirtualFile romfs;
|
2017-10-05 23:30:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Loader
|