mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-06 23:19:57 +01:00
loader: Fix compressed 3dsx icon reading
This commit is contained in:
parent
4bf9161bcd
commit
dc2ab096cb
@ -249,6 +249,17 @@ static THREEDSX_Error Load3DSXFile(Core::System& system, FileUtil::IOFile* file,
|
|||||||
return ERROR_NONE;
|
return ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppLoader_THREEDSX::AppLoader_THREEDSX(Core::System& system_, FileUtil::IOFile&& file,
|
||||||
|
const std::string& filename, const std::string& filepath)
|
||||||
|
: AppLoader(system_, std::move(file)), filename(filename), filepath(filepath) {
|
||||||
|
|
||||||
|
filetype = IdentifyType(this->file.get());
|
||||||
|
|
||||||
|
if (FileUtil::Z3DSReadIOFile::GetUnderlyingFileMagic(this->file.get()) != std::nullopt) {
|
||||||
|
this->file = std::make_unique<FileUtil::Z3DSReadIOFile>(std::move(this->file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileType AppLoader_THREEDSX::IdentifyType(FileUtil::IOFile* file) {
|
FileType AppLoader_THREEDSX::IdentifyType(FileUtil::IOFile* file) {
|
||||||
u32 magic;
|
u32 magic;
|
||||||
file->Seek(0, SEEK_SET);
|
file->Seek(0, SEEK_SET);
|
||||||
@ -270,10 +281,6 @@ ResultStatus AppLoader_THREEDSX::Load(std::shared_ptr<Kernel::Process>& process)
|
|||||||
if (!file->IsOpen())
|
if (!file->IsOpen())
|
||||||
return ResultStatus::Error;
|
return ResultStatus::Error;
|
||||||
|
|
||||||
if (FileUtil::Z3DSReadIOFile::GetUnderlyingFileMagic(file.get()) != std::nullopt) {
|
|
||||||
file = std::make_unique<FileUtil::Z3DSReadIOFile>(std::move(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<CodeSet> codeset;
|
std::shared_ptr<CodeSet> codeset;
|
||||||
if (Load3DSXFile(system, file.get(), Memory::PROCESS_IMAGE_VADDR, &codeset) != ERROR_NONE)
|
if (Load3DSXFile(system, file.get(), Memory::PROCESS_IMAGE_VADDR, &codeset) != ERROR_NONE)
|
||||||
return ResultStatus::Error;
|
return ResultStatus::Error;
|
||||||
@ -341,13 +348,12 @@ AppLoader::CompressFileInfo AppLoader_THREEDSX::GetCompressFileInfo() {
|
|||||||
info.recommended_compressed_extension = "z3dsx";
|
info.recommended_compressed_extension = "z3dsx";
|
||||||
info.recommended_uncompressed_extension = "3dsx";
|
info.recommended_uncompressed_extension = "3dsx";
|
||||||
info.underlying_magic = std::array<u8, 4>({'3', 'D', 'S', 'X'});
|
info.underlying_magic = std::array<u8, 4>({'3', 'D', 'S', 'X'});
|
||||||
info.is_compressed =
|
info.is_compressed = file->IsCompressed();
|
||||||
FileUtil::Z3DSReadIOFile::GetUnderlyingFileMagic(file.get()) != std::nullopt;
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppLoader_THREEDSX::IsFileCompressed() {
|
bool AppLoader_THREEDSX::IsFileCompressed() {
|
||||||
return FileUtil::Z3DSReadIOFile::GetUnderlyingFileMagic(file.get()) != std::nullopt;
|
return file->IsCompressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultStatus AppLoader_THREEDSX::ReadIcon(std::vector<u8>& buffer) {
|
ResultStatus AppLoader_THREEDSX::ReadIcon(std::vector<u8>& buffer) {
|
||||||
|
|||||||
@ -19,8 +19,7 @@ namespace Loader {
|
|||||||
class AppLoader_THREEDSX final : public AppLoader {
|
class AppLoader_THREEDSX final : public AppLoader {
|
||||||
public:
|
public:
|
||||||
AppLoader_THREEDSX(Core::System& system_, FileUtil::IOFile&& file, const std::string& filename,
|
AppLoader_THREEDSX(Core::System& system_, FileUtil::IOFile&& file, const std::string& filename,
|
||||||
const std::string& filepath)
|
const std::string& filepath);
|
||||||
: AppLoader(system_, std::move(file)), filename(filename), filepath(filepath) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
@ -30,7 +29,7 @@ public:
|
|||||||
static FileType IdentifyType(FileUtil::IOFile* file);
|
static FileType IdentifyType(FileUtil::IOFile* file);
|
||||||
|
|
||||||
FileType GetFileType() override {
|
FileType GetFileType() override {
|
||||||
return IdentifyType(file.get());
|
return filetype;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultStatus Load(std::shared_ptr<Kernel::Process>& process) override;
|
ResultStatus Load(std::shared_ptr<Kernel::Process>& process) override;
|
||||||
@ -46,6 +45,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string filepath;
|
std::string filepath;
|
||||||
|
FileType filetype;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Loader
|
} // namespace Loader
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user