mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
KeyValues: fix bug when loading from file
Read file as binary, and check if the file we're opening has a size.
This commit is contained in:
parent
6f11fffe63
commit
7cbb8a994d
@ -1875,7 +1875,7 @@ bool KeyValues::LoadFromFile(IBaseFileSystem* filesystem, const char* resourceNa
|
|||||||
{
|
{
|
||||||
//TM_ZONE_FILTERED( TELEMETRY_LEVEL0, 50, TMZF_NONE, "%s %s", __FUNCTION__, tmDynamicString( TELEMETRY_LEVEL0, resourceName ) );
|
//TM_ZONE_FILTERED( TELEMETRY_LEVEL0, 50, TMZF_NONE, "%s %s", __FUNCTION__, tmDynamicString( TELEMETRY_LEVEL0, resourceName ) );
|
||||||
|
|
||||||
FileHandle_t f = filesystem->Open(resourceName, "rt", pathID);
|
FileHandle_t f = filesystem->Open(resourceName, "rb", pathID);
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1883,6 +1883,10 @@ bool KeyValues::LoadFromFile(IBaseFileSystem* filesystem, const char* resourceNa
|
|||||||
|
|
||||||
// load file into a null-terminated buffer
|
// load file into a null-terminated buffer
|
||||||
const ssize_t fileSize = filesystem->Size(f);
|
const ssize_t fileSize = filesystem->Size(f);
|
||||||
|
|
||||||
|
if (!fileSize)
|
||||||
|
return false;
|
||||||
|
|
||||||
std::unique_ptr<char[]> pBuf(new char[fileSize + 1]);
|
std::unique_ptr<char[]> pBuf(new char[fileSize + 1]);
|
||||||
|
|
||||||
const ssize_t nRead = filesystem->Read(pBuf.get(), fileSize, f);
|
const ssize_t nRead = filesystem->Read(pBuf.get(), fileSize, f);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user