mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 12:19:12 +00:00
Only open file once when detecting blob type
This commit is contained in:
parent
3fdcbbdd92
commit
d1ea00ed88
9 changed files with 40 additions and 61 deletions
|
@ -56,21 +56,12 @@ void Replace32(u64 offset, u64 nbytes, u8* out_ptr, u64 replace_offset, u32 repl
|
|||
|
||||
namespace DiscIO
|
||||
{
|
||||
bool IsTGCBlob(const std::string& path)
|
||||
{
|
||||
File::IOFile file(path, "rb");
|
||||
|
||||
TGCHeader header;
|
||||
return (file.ReadArray(&header, 1) && header.magic == Common::swap32(0xAE0F38A2));
|
||||
}
|
||||
|
||||
std::unique_ptr<TGCFileReader> TGCFileReader::Create(const std::string& path)
|
||||
{
|
||||
if (IsTGCBlob(path))
|
||||
{
|
||||
File::IOFile file(path, "rb");
|
||||
File::IOFile file(path, "rb");
|
||||
TGCHeader header;
|
||||
if (file.ReadArray(&header, 1) && header.magic == TGC_MAGIC)
|
||||
return std::unique_ptr<TGCFileReader>(new TGCFileReader(std::move(file)));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue