diff options
| author | 2018-07-20 09:14:10 -0700 | |
|---|---|---|
| committer | 2018-07-20 09:14:10 -0700 | |
| commit | 86d1649b32f636bb91a3333843c45d4decd5a164 (patch) | |
| tree | 24b855b62c595af879812f8febaac6f4234ac59d /src/core/loader/nso.cpp | |
| parent | Merge pull request #731 from lioncash/shadow (diff) | |
| parent | nso: Silence implicit sign conversion warnings (diff) | |
| download | yuzu-86d1649b32f636bb91a3333843c45d4decd5a164.tar.gz yuzu-86d1649b32f636bb91a3333843c45d4decd5a164.tar.xz yuzu-86d1649b32f636bb91a3333843c45d4decd5a164.zip | |
Merge pull request #732 from lioncash/unused
nso: Minor changes
Diffstat (limited to 'src/core/loader/nso.cpp')
| -rw-r--r-- | src/core/loader/nso.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index c66561bf4..06b1b33f4 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -69,29 +69,18 @@ FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) { | |||
| 69 | static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data, | 69 | static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data, |
| 70 | const NsoSegmentHeader& header) { | 70 | const NsoSegmentHeader& header) { |
| 71 | std::vector<u8> uncompressed_data(header.size); | 71 | std::vector<u8> uncompressed_data(header.size); |
| 72 | const int bytes_uncompressed = LZ4_decompress_safe( | 72 | const int bytes_uncompressed = |
| 73 | reinterpret_cast<const char*>(compressed_data.data()), | 73 | LZ4_decompress_safe(reinterpret_cast<const char*>(compressed_data.data()), |
| 74 | reinterpret_cast<char*>(uncompressed_data.data()), compressed_data.size(), header.size); | 74 | reinterpret_cast<char*>(uncompressed_data.data()), |
| 75 | static_cast<int>(compressed_data.size()), header.size); | ||
| 75 | 76 | ||
| 76 | ASSERT_MSG(bytes_uncompressed == header.size && bytes_uncompressed == uncompressed_data.size(), | 77 | ASSERT_MSG(bytes_uncompressed == static_cast<int>(header.size) && |
| 78 | bytes_uncompressed == static_cast<int>(uncompressed_data.size()), | ||
| 77 | "{} != {} != {}", bytes_uncompressed, header.size, uncompressed_data.size()); | 79 | "{} != {} != {}", bytes_uncompressed, header.size, uncompressed_data.size()); |
| 78 | 80 | ||
| 79 | return uncompressed_data; | 81 | return uncompressed_data; |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | static std::vector<u8> ReadSegment(FileUtil::IOFile& file, const NsoSegmentHeader& header, | ||
| 83 | size_t compressed_size) { | ||
| 84 | std::vector<u8> compressed_data(compressed_size); | ||
| 85 | |||
| 86 | file.Seek(header.offset, SEEK_SET); | ||
| 87 | if (compressed_size != file.ReadBytes(compressed_data.data(), compressed_size)) { | ||
| 88 | LOG_CRITICAL(Loader, "Failed to read {} NSO LZ4 compressed bytes", compressed_size); | ||
| 89 | return {}; | ||
| 90 | } | ||
| 91 | |||
| 92 | return DecompressSegment(compressed_data, header); | ||
| 93 | } | ||
| 94 | |||
| 95 | static constexpr u32 PageAlignSize(u32 size) { | 84 | static constexpr u32 PageAlignSize(u32 size) { |
| 96 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; | 85 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; |
| 97 | } | 86 | } |