[+] AuFS::ReadFileHeader
This commit is contained in:
parent
f0248ed658
commit
c54ac9d6a3
@ -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
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user