pineapple-src/src/core/loader/nro.h

63 lines
1.5 KiB
C
Raw Normal View History

2022-04-23 14:49:07 -04:00
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2020-12-28 10:15:37 -05:00
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "common/common_types.h"
#include "core/loader/loader.h"
namespace Core {
class System;
}
namespace FileSys {
class NACP;
}
namespace Kernel {
2021-05-05 22:45:54 -04:00
class KProcess;
2020-12-28 10:15:37 -05:00
}
namespace Loader {
/// Loads an NRO file
class AppLoader_NRO final : public AppLoader {
public:
2021-04-27 23:28:56 -04:00
explicit AppLoader_NRO(FileSys::VirtualFile file_);
2020-12-28 10:15:37 -05:00
~AppLoader_NRO() override;
/**
2021-04-27 23:28:56 -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.
2020-12-28 10:15:37 -05:00
*/
2021-04-27 23:28:56 -04:00
static FileType IdentifyType(const FileSys::VirtualFile& nro_file);
2020-12-28 10:15:37 -05:00
FileType GetFileType() const override {
return IdentifyType(file);
}
2021-05-05 22:45:54 -04:00
LoadResult Load(Kernel::KProcess& process, Core::System& system) override;
2020-12-28 10:15:37 -05: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;
ResultStatus ReadControlData(FileSys::NACP& control) override;
bool IsRomFSUpdatable() const override;
private:
2021-05-05 22:45:54 -04:00
bool LoadNro(Kernel::KProcess& process, const FileSys::VfsFile& nro_file);
2020-12-28 10:15:37 -05:00
std::vector<u8> icon_data;
std::unique_ptr<FileSys::NACP> nacp;
FileSys::VirtualFile romfs;
};
} // namespace Loader