IsGCZBlob: try to leave the file position where it was before

callers that don't seek afterwards might be missing a few bytes that way.
This commit is contained in:
BhaaL 2017-01-21 21:26:19 +01:00
parent 9fb01ecc73
commit 24be8c0814
1 changed files with 6 additions and 1 deletions

View File

@ -410,8 +410,13 @@ bool DecompressBlobToFile(const std::string& infile_path, const std::string& out
bool IsGCZBlob(File::IOFile& file)
{
const u64 position = file.Tell();
if (!file.Seek(0, SEEK_SET))
return false;
CompressedBlobHeader header;
return file.Seek(0, SEEK_SET) && file.ReadArray(&header, 1) && header.magic_cookie == GCZ_MAGIC;
bool is_gcz = file.ReadArray(&header, 1) && header.magic_cookie == GCZ_MAGIC;
file.Seek(position, SEEK_SET);
return is_gcz;
}
} // namespace