[+] AuFS::ReadFileHeader

This commit is contained in:
Reece Wilson 2024-03-17 21:09:09 +00:00
parent f0248ed658
commit c54ac9d6a3
2 changed files with 16 additions and 0 deletions

View File

@ -132,6 +132,8 @@ namespace Aurora::IO::FS
*/
AUKN_SYM bool ReadString(const AuString &path, AuString &buffer);
AUKN_SYM bool ReadFileHeader(const AuString &path, AuUInt16 uLength, Memory::ByteBuffer &buffer);
/**
* @brief Returns a non-atomic non-promise that the requested file didn't exist.
* > Use appropriate file locks and check for open file related errors when relevant

View File

@ -338,6 +338,20 @@ namespace Aurora::IO::FS
return Locale::Encoding::DecodeUTF8(fileBuffer.data(), fileBuffer.size(), buffer, Locale::ECodePage::eUTF8).first != 0;
}
AUKN_SYM bool ReadFileHeader(const AuString &path, AuUInt16 uLength, Memory::ByteBuffer &buffer)
{
AuUInt uSize {};
auto memView = buffer.GetOrAllocateLinearWriteable(uLength);
SysCheckNotNullMemory(memView, false);
auto pStream = FS::OpenReadUnique(path);
SysCheckNotNullNested(pStream, false);
SysCheckNotNull(pStream->Read({ memView, uSize }), false);
buffer.writePtr += uSize;
return true;
}
AUKN_SYM bool WriteString(const AuString &path, const AuString &str)
{
char bom[3]