Only open file once when detecting blob type

This commit is contained in:
JosJuice
2016-12-21 11:30:12 +01:00
parent 3fdcbbdd92
commit d1ea00ed88
9 changed files with 40 additions and 61 deletions

View File

@ -28,6 +28,8 @@
namespace DiscIO
{
bool IsGCZBlob(const std::string& filename);
CompressedBlobReader::CompressedBlobReader(const std::string& filename) : m_file_name(filename)
{
m_file.Open(filename, "rb");
@ -192,7 +194,7 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u
callback(GetStringT("Files opened, ready to compress."), 0, arg);
CompressedBlobHeader header;
header.magic_cookie = kBlobCookie;
header.magic_cookie = GCZ_MAGIC;
header.sub_type = sub_type;
header.block_size = block_size;
header.data_size = File::GetSize(infile);
@ -401,7 +403,7 @@ bool IsGCZBlob(const std::string& filename)
File::IOFile f(filename, "rb");
CompressedBlobHeader header;
return f.ReadArray(&header, 1) && (header.magic_cookie == kBlobCookie);
return f.ReadArray(&header, 1) && (header.magic_cookie == GCZ_MAGIC);
}
} // namespace