diff options
author | bunnei <bunneidev@gmail.com> | 2019-04-06 05:35:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-06 05:35:54 +0200 |
commit | b8fbd125e682b17bf373d406eec65011f7e16f5f (patch) | |
tree | 187483b9de889a9d37fc0e0fa30fd0a8911dd101 /src/core/file_sys/program_metadata.cpp | |
parent | Merge pull request #2337 from lioncash/temporary (diff) | |
parent | file_sys/program_metadata: Remove obsolete TODOs (diff) | |
download | yuzu-b8fbd125e682b17bf373d406eec65011f7e16f5f.tar yuzu-b8fbd125e682b17bf373d406eec65011f7e16f5f.tar.gz yuzu-b8fbd125e682b17bf373d406eec65011f7e16f5f.tar.bz2 yuzu-b8fbd125e682b17bf373d406eec65011f7e16f5f.tar.lz yuzu-b8fbd125e682b17bf373d406eec65011f7e16f5f.tar.xz yuzu-b8fbd125e682b17bf373d406eec65011f7e16f5f.tar.zst yuzu-b8fbd125e682b17bf373d406eec65011f7e16f5f.zip |
Diffstat (limited to 'src/core/file_sys/program_metadata.cpp')
-rw-r--r-- | src/core/file_sys/program_metadata.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index d3e00437f..d863253f8 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include <cstddef> -#include <cstring> #include <vector> #include "common/logging/log.h" @@ -17,28 +16,30 @@ ProgramMetadata::ProgramMetadata() = default; ProgramMetadata::~ProgramMetadata() = default; Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) { - std::size_t total_size = static_cast<std::size_t>(file->GetSize()); - if (total_size < sizeof(Header)) + const std::size_t total_size = file->GetSize(); + if (total_size < sizeof(Header)) { return Loader::ResultStatus::ErrorBadNPDMHeader; + } - // TODO(DarkLordZach): Use ReadObject when Header/AcidHeader becomes trivially copyable. - std::vector<u8> npdm_header_data = file->ReadBytes(sizeof(Header)); - if (sizeof(Header) != npdm_header_data.size()) + if (sizeof(Header) != file->ReadObject(&npdm_header)) { return Loader::ResultStatus::ErrorBadNPDMHeader; - std::memcpy(&npdm_header, npdm_header_data.data(), sizeof(Header)); + } - std::vector<u8> acid_header_data = file->ReadBytes(sizeof(AcidHeader), npdm_header.acid_offset); - if (sizeof(AcidHeader) != acid_header_data.size()) + if (sizeof(AcidHeader) != file->ReadObject(&acid_header, npdm_header.acid_offset)) { return Loader::ResultStatus::ErrorBadACIDHeader; - std::memcpy(&acid_header, acid_header_data.data(), sizeof(AcidHeader)); + } - if (sizeof(AciHeader) != file->ReadObject(&aci_header, npdm_header.aci_offset)) + if (sizeof(AciHeader) != file->ReadObject(&aci_header, npdm_header.aci_offset)) { return Loader::ResultStatus::ErrorBadACIHeader; + } - if (sizeof(FileAccessControl) != file->ReadObject(&acid_file_access, acid_header.fac_offset)) + if (sizeof(FileAccessControl) != file->ReadObject(&acid_file_access, acid_header.fac_offset)) { return Loader::ResultStatus::ErrorBadFileAccessControl; - if (sizeof(FileAccessHeader) != file->ReadObject(&aci_file_access, aci_header.fah_offset)) + } + + if (sizeof(FileAccessHeader) != file->ReadObject(&aci_file_access, aci_header.fah_offset)) { return Loader::ResultStatus::ErrorBadFileAccessHeader; + } aci_kernel_capabilities.resize(aci_header.kac_size / sizeof(u32)); const u64 read_size = aci_header.kac_size; |