Refactor: is_exr_file checks memory buffer

All places that used is_exr_file already had first four bytes
of the file read into memory. So make is_exr_file work just
like is_dds_file does and check those bytes directly, no need
to hit stdio again.
This commit is contained in:
Aras Pranckevicius
2024-11-04 15:52:30 +00:00
committed by Baldur Karlsson
parent 6a05176075
commit 02fd7ac0cd
5 changed files with 12 additions and 19 deletions
+2 -2
View File
@@ -433,7 +433,7 @@ RDResult IMG_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver)
FileIO::fseek64(f, 0, SEEK_SET);
// make sure the file is a type we recognise before going further
if(is_exr_file(f))
if(is_exr_file(headerBuffer, headerSize))
{
FileIO::fseek64(f, 0, SEEK_END);
uint64_t size = FileIO::ftell64(f);
@@ -645,7 +645,7 @@ void ImageViewer::RefreshFile()
uint64_t fileSize = FileIO::ftell64(f);
FileIO::fseek64(f, 0, SEEK_SET);
if(is_exr_file(f))
if(is_exr_file(headerBuffer, headerSize))
{
texDetails.format = rgba32_float;