archive_ncch: add open source country list archive

This commit is contained in:
Weiyi Wang 2018-09-22 16:11:57 -04:00
parent d1a576eb14
commit 1123580738
2 changed files with 18286 additions and 30 deletions

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,7 @@
#include "core/hle/service/am/am.h" #include "core/hle/service/am/am.h"
#include "core/hle/service/fs/archive.h" #include "core/hle/service/fs/archive.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "country_list.app.romfs.h"
#include "shared_font.app.romfs.h" #include "shared_font.app.romfs.h"
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@ -125,47 +126,43 @@ ResultVal<std::unique_ptr<FileBackend>> NCCHArchive::OpenFile(const Path& path,
LOG_DEBUG(Service_FS, "Full Path: {}. Category: 0x{:X}. Path: 0x{:X}.", path.DebugStr(), LOG_DEBUG(Service_FS, "Full Path: {}. Category: 0x{:X}. Path: 0x{:X}.", path.DebugStr(),
high, low); high, low);
std::string archive_name; std::vector<u8> archive_data;
if (high == shared_data_archive) { if (high == shared_data_archive) {
if (low == mii_data) if (low == mii_data) {
archive_name = "Mii Data"; LOG_ERROR(Service_FS, "Failed to get a handle for shared data archive: Mii Data.");
else if (low == region_manifest) Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles,
archive_name = "Region manifest"; "Mii Data");
else if (low == shared_font) { } else if (low == region_manifest) {
LOG_WARNING(
Service_FS,
"Country list file missing. Loading open source replacement from memory");
archive_data =
std::vector<u8>(std::begin(COUNTRY_LIST_DATA), std::end(COUNTRY_LIST_DATA));
} else if (low == shared_font) {
LOG_WARNING( LOG_WARNING(
Service_FS, Service_FS,
"Shared Font file missing. Loading open source replacement from memory"); "Shared Font file missing. Loading open source replacement from memory");
const std::vector<u8> shared_font_file(std::begin(SHARED_FONT_DATA), archive_data =
std::end(SHARED_FONT_DATA)); std::vector<u8>(std::begin(SHARED_FONT_DATA), std::end(SHARED_FONT_DATA));
u64 romfs_offset = 0;
u64 romfs_size = shared_font_file.size();
std::unique_ptr<DelayGenerator> delay_generator =
std::make_unique<RomFSDelayGenerator>();
file = std::make_unique<IVFCFileInMemory>(std::move(shared_font_file), romfs_offset,
romfs_size, std::move(delay_generator));
return MakeResult<std::unique_ptr<FileBackend>>(std::move(file));
} }
} else if (high == system_data_archive) { } else if (high == system_data_archive) {
if (low == ng_word_list) if (low == ng_word_list) {
LOG_WARNING( LOG_WARNING(
Service_FS, Service_FS,
"Bad Word List file missing. Loading open source replacement from memory"); "Bad Word List file missing. Loading open source replacement from memory");
const std::vector<u8> bad_word_list_file(std::begin(BAD_WORD_LIST_DATA), archive_data =
std::end(BAD_WORD_LIST_DATA)); std::vector<u8>(std::begin(BAD_WORD_LIST_DATA), std::end(BAD_WORD_LIST_DATA));
u64 romfs_offset = 0; }
u64 romfs_size = bad_word_list_file.size();
std::unique_ptr<DelayGenerator> delay_generator =
std::make_unique<RomFSDelayGenerator>();
file = std::make_unique<IVFCFileInMemory>(std::move(bad_word_list_file), romfs_offset,
romfs_size, std::move(delay_generator));
return MakeResult<std::unique_ptr<FileBackend>>(std::move(file));
} }
if (!archive_name.empty()) { if (!archive_data.empty()) {
LOG_ERROR(Service_FS, "Failed to get a handle for shared data archive: {}. ", u64 romfs_offset = 0;
archive_name); u64 romfs_size = archive_data.size();
Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles, std::unique_ptr<DelayGenerator> delay_generator =
archive_name.c_str()); std::make_unique<RomFSDelayGenerator>();
file = std::make_unique<IVFCFileInMemory>(std::move(archive_data), romfs_offset,
romfs_size, std::move(delay_generator));
return MakeResult<std::unique_ptr<FileBackend>>(std::move(file));
} }
return ERROR_NOT_FOUND; return ERROR_NOT_FOUND;
} }