From f401c6f750ec3e9cf0adf39bca67c1df7028cd64 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Mon, 11 Mar 2024 17:13:27 +0000 Subject: [PATCH] [*] Update consistency in 895ef058 --- Source/IO/FS/FS.cpp | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/Source/IO/FS/FS.cpp b/Source/IO/FS/FS.cpp index b850f3d8..6ae6eabf 100644 --- a/Source/IO/FS/FS.cpp +++ b/Source/IO/FS/FS.cpp @@ -337,13 +337,21 @@ namespace Aurora::IO::FS return false; } - bool ok {}; - ok = pStream->Write(AuMemoryViewStreamRead { bom }); - ok &= pStream->Write(AuMemoryViewStreamRead { str }); + bool bOk {}; + bOk = pStream->Write(AuMemoryViewStreamRead { bom }); + if (auto uLength = str.length()) + { + bOk &= pStream->Write(AuMemoryViewStreamRead { str, uLength }); + bOk &= uLength == uLength; + } + else + { + bOk = true; + } pStream->Flush(); pStream->WriteEoS(); - return ok; + return bOk; } AUKN_SYM bool WriteNewString(const AuString &path, const AuString &str) @@ -373,10 +381,15 @@ namespace Aurora::IO::FS } bOk = pStream->Write(AuMemoryViewStreamRead { bom }); - bOk &= pStream->Write(AuMemoryViewStreamRead { str, uLength }); - - bOk &= uLength == str.length(); - + if (auto uLength = str.length()) + { + bOk &= pStream->Write(AuMemoryViewStreamRead { str, uLength }); + bOk &= uLength == uLength; + } + else + { + bOk = true; + } pStream->WriteEoS(); pStream->Flush(); } @@ -409,11 +422,17 @@ namespace Aurora::IO::FS return false; } - bOk = pStream->Write(AuMemoryViewStreamRead { blob, uLength }); + if (blob.length) + { + bOk = pStream->Write(AuMemoryViewStreamRead { blob, uLength }); + bOk &= uLength == blob.length; + } + else + { + bOk = true; + } pStream->WriteEoS(); pStream->Flush(); - - bOk &= uLength == blob.length; } RuntimeWaitForSecondaryTick();