[*] Allow empty file creation via NULL memoryviews

This commit is contained in:
Reece Wilson 2024-01-14 14:15:11 +00:00
parent 363560e9e9
commit 895ef05887

View File

@ -348,14 +348,15 @@ namespace Aurora::IO::FS
AUKN_SYM bool WriteNewString(const AuString &path, const AuString &str)
{
AuIO::IOHandle handle;
bool bOk {};
AuUInt uLength {};
static const char bom[3]
{
'\xEF', '\xBB', '\xBF'
};
bool bOk {};
{
AuIO::IOHandle handle;
AuUInt uLength {};
auto createRequest = AuIO::IIOHandle::HandleCreate::ReadWrite(path);
createRequest.bAlwaysCreateDirTree = true;
@ -378,6 +379,9 @@ namespace Aurora::IO::FS
pStream->WriteEoS();
pStream->Flush();
}
RuntimeWaitForSecondaryTick();
return bOk;
}
@ -385,6 +389,8 @@ namespace Aurora::IO::FS
AUKN_SYM bool WriteNewFile(const AuString &path, const Memory::MemoryViewRead &blob)
{
bool bOk {};
{
AuUInt uLength {};
AuIO::IOHandle handle;
@ -408,6 +414,9 @@ namespace Aurora::IO::FS
pStream->Flush();
bOk &= uLength == blob.length;
}
RuntimeWaitForSecondaryTick();
return bOk;
}
@ -432,11 +441,18 @@ namespace Aurora::IO::FS
return false;
}
if (blob.length)
{
bOk = pStream->Write(AuMemoryViewStreamRead { blob, uLength });
pStream->WriteEoS();
pStream->Flush();
bOk &= uLength == blob.length;
}
else
{
bOk = true;
}
pStream->WriteEoS();
pStream->SetFlushOnClose(true);
return bOk;
}