From 351d94e0e87efb44102d6979519737ba0bb48f31 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 20 May 2021 06:33:28 -0400 Subject: [PATCH] ReadStrSized32 --- BeefLibs/corlib/src/IO/Stream.bf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BeefLibs/corlib/src/IO/Stream.bf b/BeefLibs/corlib/src/IO/Stream.bf index 6798c4aa..00e8bab5 100644 --- a/BeefLibs/corlib/src/IO/Stream.bf +++ b/BeefLibs/corlib/src/IO/Stream.bf @@ -97,10 +97,10 @@ namespace System.IO } } - //Read sized string from stream - public Result ReadStrSized32(int64 size, String output) + /// Read sized string from stream + public Result ReadStrSized32(int size, String output) { - if (size <= 0) + if (size < 0) return .Err; for (int64 i = 0; i < size; i++) @@ -115,7 +115,13 @@ namespace System.IO 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 ReadStrSized32(String output) + { + int size = Try!(Read()); + return ReadStrSized32(size, output); + } + + /// Reads null terminated ASCII string from the stream. Null terminator is read from stream but isn't appended to output string public Result ReadStrC(String output) { Result char0;