ref: 8b39fba2b9ed0619abea27eddd129d7b2c8c8178
dir: /libstd/slurp.myr/
use "types.use" use "alloc.use" use "die.use" use "sys.use" use "fmt.use" use "extremum.use" pkg std = const slurp : (path : byte[:] -> byte[:]) ;; const Bufinc = 4096 const slurp = {path var fd var n var len var buf fd = open(path, Ordonly, 0o777) if fd < 0 die("Could not open file") ;; len = 0 buf = slalloc(Bufinc) while true n = read(fd, buf[len:]) if n == 0 goto done ;; len += n buf = slgrow(buf, len + Bufinc) ;; :done -> buf[:len] }