Skip to content

Modern Fs Stream ReadExact

Paul Squires edited this page Oct 22, 2026 · 3 revisions

Home › Filesystem › File Streams › Stream.ReadExact

Stream.ReadExact

Reads exactly n bytes, or fails if the data ends first.

Syntax

Stream.ReadExact( buf, n )

Notes

  • Reads exactly n bytes, calling Read as often as it takes.
  • If the data ends first it fails with FS_UNEXPECTED_EOF, and the bytes it did read stay in buf.

Examples

#import "std/fs"
using fs

dim as MemoryStream m = MemoryStream( "abc" )
dim as ubyte b( 0 to 3 )
print m.ReadExact( @b(0), 2 ).IsOk( )    '' true
print m.ReadExact( @b(0), 2 ).Failure( ).Message( )    '' unexpected end of data

Library: Filesystem Library Category: File Streams Documented under: Streams

Clone this wiki locally