RTech: add param to LoadFromFile for parse failures

Gets set if parsing failed.
This commit is contained in:
Kawe Mazidjatari 2024-11-14 13:38:28 +01:00
parent 1909ad63ab
commit abe5578557
2 changed files with 6 additions and 3 deletions

View File

@ -82,7 +82,7 @@ public:
public:
static Node_t* LoadFromBuffer(const char* pszBufferName, char* pBuffer, eFieldType rootType);
static Node_t* LoadFromFile(const char* pszFilePath, const char* pPathID = nullptr);
static Node_t* LoadFromFile(const char* pszFilePath, const char* pPathID = nullptr, bool* parseFailure = nullptr);
};

View File

@ -22,7 +22,7 @@ RSON::Node_t* RSON::LoadFromBuffer(const char* pszBufferName, char* pBuffer, RSO
// *pPathID -
// Output : pointer to RSON object on success, nullptr otherwise
//-----------------------------------------------------------------------------
RSON::Node_t* RSON::LoadFromFile(const char* pszFilePath, const char* pPathID)
RSON::Node_t* RSON::LoadFromFile(const char* pszFilePath, const char* pPathID, bool* parseFailure)
{
FileHandle_t file = FileSystem()->Open(pszFilePath, "rt", pPathID);
@ -36,7 +36,10 @@ RSON::Node_t* RSON::LoadFromFile(const char* pszFilePath, const char* pPathID)
FileSystem()->Close(file);
fileBuf[nRead] = '\0';
RSON::Node_t* node = RSON::LoadFromBuffer(pszFilePath, fileBuf.get(), eFieldType::RSON_OBJECT);
if (!node && parseFailure)
*parseFailure = true;
return node;
}