diff options
| author | 2015-01-06 23:10:13 +0000 | |
|---|---|---|
| committer | 2015-01-15 22:23:08 +0100 | |
| commit | 82ec17db7df53ed1c376d1cdaa9a6587719a546d (patch) | |
| tree | 3c2236849146037fbba2fb75ea8a50f53b847a17 /src/core/loader/3dsx.cpp | |
| parent | Loader: Don’t assume the file hasn’t been read before. (diff) | |
| download | yuzu-82ec17db7df53ed1c376d1cdaa9a6587719a546d.tar.gz yuzu-82ec17db7df53ed1c376d1cdaa9a6587719a546d.tar.xz yuzu-82ec17db7df53ed1c376d1cdaa9a6587719a546d.zip | |
Loader: Guess filetype from the magic, or fallback to the extension.
Diffstat (limited to 'src/core/loader/3dsx.cpp')
| -rw-r--r-- | src/core/loader/3dsx.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index e239808f3..f3e09ecd6 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp | |||
| @@ -44,7 +44,6 @@ enum THREEDSX_Error { | |||
| 44 | static const u32 RELOCBUFSIZE = 512; | 44 | static const u32 RELOCBUFSIZE = 512; |
| 45 | 45 | ||
| 46 | // File header | 46 | // File header |
| 47 | static const u32 THREEDSX_MAGIC = 0x58534433; // '3DSX' | ||
| 48 | #pragma pack(1) | 47 | #pragma pack(1) |
| 49 | struct THREEDSX_Header | 48 | struct THREEDSX_Header |
| 50 | { | 49 | { |
| @@ -202,6 +201,18 @@ static THREEDSX_Error Load3DSXFile(FileUtil::IOFile& file, u32 base_addr) | |||
| 202 | return ERROR_NONE; | 201 | return ERROR_NONE; |
| 203 | } | 202 | } |
| 204 | 203 | ||
| 204 | FileType AppLoader_THREEDSX::IdentifyType(FileUtil::IOFile& file) { | ||
| 205 | u32 magic; | ||
| 206 | file.Seek(0, SEEK_SET); | ||
| 207 | if (1 != file.ReadArray<u32>(&magic, 1)) | ||
| 208 | return FileType::Error; | ||
| 209 | |||
| 210 | if (MakeMagic('3', 'D', 'S', 'X') == magic) | ||
| 211 | return FileType::THREEDSX; | ||
| 212 | |||
| 213 | return FileType::Error; | ||
| 214 | } | ||
| 215 | |||
| 205 | ResultStatus AppLoader_THREEDSX::Load() { | 216 | ResultStatus AppLoader_THREEDSX::Load() { |
| 206 | if (is_loaded) | 217 | if (is_loaded) |
| 207 | return ResultStatus::ErrorAlreadyLoaded; | 218 | return ResultStatus::ErrorAlreadyLoaded; |