mirror of
https://github.com/AntonioND/nitro-engine.git
synced 2025-06-18 16:45:33 -04:00
library: Check for errors properly in FAT functions
This commit is contained in:
parent
334c1aa9ab
commit
056042cd31
@ -17,7 +17,13 @@ char *NE_FATLoadData(const char *filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
if (fseek(f, 0, SEEK_END) != 0)
|
||||
{
|
||||
NE_DebugPrint("Failed to fseek: %s", filename);
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t size = ftell(f);
|
||||
rewind(f);
|
||||
|
||||
@ -25,12 +31,14 @@ char *NE_FATLoadData(const char *filename)
|
||||
if (buffer == NULL)
|
||||
{
|
||||
NE_DebugPrint("Not enought memory to load %s", filename);
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fread(buffer, 1, size, f) != size)
|
||||
{
|
||||
NE_DebugPrint("Failed to read data of %s", filename);
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -47,7 +55,13 @@ size_t NE_FATFileSize(const char *filename)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
if (fseek(f, 0, SEEK_END) != 0)
|
||||
{
|
||||
NE_DebugPrint("Failed to fseek: %s", filename);
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t size = ftell(f);
|
||||
fclose(f);
|
||||
return size;
|
||||
|
Loading…
Reference in New Issue
Block a user