1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Add ReadNullTerminatedString to System.IO.Stream

Function that reads a null terminated string from the stream.
This commit is contained in:
moneyl 2021-03-16 19:39:38 -04:00
parent 7cc95c2b07
commit a1e15ecb73

View file

@ -115,6 +115,22 @@ namespace System.IO
return .Ok; return .Ok;
} }
//Reads null terminated ASCII string from the stream. Null terminator is read from stream but isn't appended to output string
public Result<void> ReadNullTerminatedString(String output)
{
Result<char8> char0;
while(true)
{
char0 = Read<char8>();
if(char0 == .Err)
return .Err;
if(char0.Value == '\0')
return .Ok;
output.Append(char0.Value);
}
}
public Result<T> Read<T>() where T : struct public Result<T> Read<T>() where T : struct
{ {
T val = ?; T val = ?;