diff options
author | bunnei <bunneidev@gmail.com> | 2016-05-05 18:35:24 -0400 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2016-05-05 18:35:24 -0400 |
commit | 55946cdc119c53656c79667b9a81172563b443ad (patch) | |
tree | 1fc81259c565ed89e17029a859c06ec8231728aa /src/core/loader/3dsx.cpp | |
parent | 24d064e8300d19272a2b527687ab889f351d8bf5 (diff) | |
parent | 9da1534237dfbe72be36200453dc52fce38ae557 (diff) |
Merge pull request #1700 from wwylele/gamelist-icon
Qt: display game icon and title in the game list
Diffstat (limited to 'src/core/loader/3dsx.cpp')
-rw-r--r-- | src/core/loader/3dsx.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index 5fb3b9e2b..48a11ef81 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp @@ -303,4 +303,31 @@ ResultStatus AppLoader_THREEDSX::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& ro return ResultStatus::ErrorNotUsed; } +ResultStatus AppLoader_THREEDSX::ReadIcon(std::vector<u8>& buffer) { + if (!file.IsOpen()) + return ResultStatus::Error; + + // Reset read pointer in case this file has been read before. + file.Seek(0, SEEK_SET); + + THREEDSX_Header hdr; + if (file.ReadBytes(&hdr, sizeof(THREEDSX_Header)) != sizeof(THREEDSX_Header)) + return ResultStatus::Error; + + if (hdr.header_size != sizeof(THREEDSX_Header)) + return ResultStatus::Error; + + // Check if the 3DSX has a SMDH... + if (hdr.smdh_offset != 0) { + file.Seek(hdr.smdh_offset, SEEK_SET); + buffer.resize(hdr.smdh_size); + + if (file.ReadBytes(&buffer[0], hdr.smdh_size) != hdr.smdh_size) + return ResultStatus::Error; + + return ResultStatus::Success; + } + return ResultStatus::ErrorNotUsed; +} + } // namespace Loader |