mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-14 05:55:13 +01:00
filesys/archive_ncch: specify endianness for enum
NCCHArchivePath::media_type is unchanged because its underlying type is unclear
This commit is contained in:
parent
2badaf43b0
commit
9564b4b292
@ -12,6 +12,7 @@
|
|||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
|
#include "common/swap.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/file_sys/archive_ncch.h"
|
#include "core/file_sys/archive_ncch.h"
|
||||||
#include "core/file_sys/errors.h"
|
#include "core/file_sys/errors.h"
|
||||||
@ -35,9 +36,9 @@ struct NCCHArchivePath {
|
|||||||
static_assert(sizeof(NCCHArchivePath) == 0x10, "NCCHArchivePath has wrong size!");
|
static_assert(sizeof(NCCHArchivePath) == 0x10, "NCCHArchivePath has wrong size!");
|
||||||
|
|
||||||
struct NCCHFilePath {
|
struct NCCHFilePath {
|
||||||
u32_le open_type;
|
enum_le<NCCHFileOpenType> open_type;
|
||||||
u32_le content_index;
|
u32_le content_index;
|
||||||
u32_le filepath_type;
|
enum_le<NCCHFilePathType> filepath_type;
|
||||||
std::array<char, 8> exefs_filepath;
|
std::array<char, 8> exefs_filepath;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NCCHFilePath) == 0x14, "NCCHFilePath has wrong size!");
|
static_assert(sizeof(NCCHFilePath) == 0x14, "NCCHFilePath has wrong size!");
|
||||||
@ -55,9 +56,9 @@ Path MakeNCCHArchivePath(u64 tid, Service::FS::MediaType media_type) {
|
|||||||
Path MakeNCCHFilePath(NCCHFileOpenType open_type, u32 content_index, NCCHFilePathType filepath_type,
|
Path MakeNCCHFilePath(NCCHFileOpenType open_type, u32 content_index, NCCHFilePathType filepath_type,
|
||||||
std::array<char, 8>& exefs_filepath) {
|
std::array<char, 8>& exefs_filepath) {
|
||||||
NCCHFilePath path;
|
NCCHFilePath path;
|
||||||
path.open_type = static_cast<u32_le>(open_type);
|
path.open_type = open_type;
|
||||||
path.content_index = static_cast<u32_le>(content_index);
|
path.content_index = static_cast<u32_le>(content_index);
|
||||||
path.filepath_type = static_cast<u32_le>(filepath_type);
|
path.filepath_type = filepath_type;
|
||||||
path.exefs_filepath = exefs_filepath;
|
path.exefs_filepath = exefs_filepath;
|
||||||
std::vector<u8> file(sizeof(path));
|
std::vector<u8> file(sizeof(path));
|
||||||
std::memcpy(&file[0], &path, sizeof(path));
|
std::memcpy(&file[0], &path, sizeof(path));
|
||||||
@ -88,15 +89,14 @@ ResultVal<std::unique_ptr<FileBackend>> NCCHArchive::OpenFile(const Path& path,
|
|||||||
std::unique_ptr<FileBackend> file;
|
std::unique_ptr<FileBackend> file;
|
||||||
|
|
||||||
// NCCH RomFS
|
// NCCH RomFS
|
||||||
NCCHFilePathType filepath_type = static_cast<NCCHFilePathType>(openfile_path.filepath_type);
|
if (openfile_path.filepath_type == NCCHFilePathType::RomFS) {
|
||||||
if (filepath_type == NCCHFilePathType::RomFS) {
|
|
||||||
std::shared_ptr<RomFSReader> romfs_file;
|
std::shared_ptr<RomFSReader> romfs_file;
|
||||||
|
|
||||||
result = ncch_container.ReadRomFS(romfs_file);
|
result = ncch_container.ReadRomFS(romfs_file);
|
||||||
std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<RomFSDelayGenerator>();
|
std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<RomFSDelayGenerator>();
|
||||||
file = std::make_unique<IVFCFile>(std::move(romfs_file), std::move(delay_generator));
|
file = std::make_unique<IVFCFile>(std::move(romfs_file), std::move(delay_generator));
|
||||||
} else if (filepath_type == NCCHFilePathType::Code ||
|
} else if (openfile_path.filepath_type == NCCHFilePathType::Code ||
|
||||||
filepath_type == NCCHFilePathType::ExeFS) {
|
openfile_path.filepath_type == NCCHFilePathType::ExeFS) {
|
||||||
std::vector<u8> buffer;
|
std::vector<u8> buffer;
|
||||||
|
|
||||||
// Load NCCH .code or icon/banner/logo
|
// Load NCCH .code or icon/banner/logo
|
||||||
@ -104,7 +104,8 @@ ResultVal<std::unique_ptr<FileBackend>> NCCHArchive::OpenFile(const Path& path,
|
|||||||
std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<ExeFSDelayGenerator>();
|
std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<ExeFSDelayGenerator>();
|
||||||
file = std::make_unique<NCCHFile>(std::move(buffer), std::move(delay_generator));
|
file = std::make_unique<NCCHFile>(std::move(buffer), std::move(delay_generator));
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Service_FS, "Unknown NCCH archive type {}!", openfile_path.filepath_type);
|
LOG_ERROR(Service_FS, "Unknown NCCH archive type {}!",
|
||||||
|
static_cast<u32>(openfile_path.filepath_type));
|
||||||
result = Loader::ResultStatus::Error;
|
result = Loader::ResultStatus::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user