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:
parent
7cc95c2b07
commit
a1e15ecb73
1 changed files with 16 additions and 0 deletions
|
@ -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 = ?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue