ref: 3668e19263f2c0a17055eb6fc31c97b16617f32d
dir: /test/bio-peek.myr/
use std use bio const main = { var f /* Must be bigger than a bio buffer (ie, > 64k) */ var buf : byte[64*1024] match bio.open("data/datafile", bio.Rd) | `std.Some bio: f = bio | `std.None: std.fatal(1, "Unable to open data file") ;; std.assert(bio.peekb(f) == 0x30, "wrong byte value read from datafile") std.assert(bio.peekc(f) == '0', "wrong char value read from datafile") bio.read(f, buf[:4]) /* skip ahead 4 bytes */ std.assert(bio.peekb(f) == 0x34, "wrong byte value read from datafile") std.assert(bio.peekc(f) == '4', "wrong char value read from datafile") bio.read(f, buf[:]) /* skip ahead 64k */ std.assert(bio.peekb(f) == 0x30, "wrong byte value read from datafile") std.assert(bio.peekc(f) == '0', "wrong char value read from datafile") bio.close(f); std.put("Succeded peeeking values\n") }