From abe5578557b4e2ed54a5eb7ca4a36233de17cad4 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:38:28 +0100 Subject: [PATCH] RTech: add param to LoadFromFile for parse failures Gets set if parsing failed. --- src/public/rtech/rson.h | 2 +- src/rtech/rdf/rson.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/public/rtech/rson.h b/src/public/rtech/rson.h index c8628efd..b876c99b 100644 --- a/src/public/rtech/rson.h +++ b/src/public/rtech/rson.h @@ -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); }; diff --git a/src/rtech/rdf/rson.cpp b/src/rtech/rdf/rson.cpp index ebb9c2d8..27b2f0e4 100644 --- a/src/rtech/rdf/rson.cpp +++ b/src/rtech/rdf/rson.cpp @@ -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; } \ No newline at end of file