duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit ff1be173994dd898a6e4c879105f53fbcc284ae6
parent 6b970f0b122323c9c9f5c276e7c324f262d2722d
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun, 29 Jan 2023 09:27:42 -0500

sys/io: add MemIO :range

Diffstat:
Mfs/doc/sys/io.txt | 3+++
Mfs/sys/io.fs | 1+
2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/fs/doc/sys/io.txt b/fs/doc/sys/io.txt @@ -227,6 +227,9 @@ Words: :new ( a u -- hdl ) Allocate a new MemIO pointing to address range "a u". +:range ( hdl -- a u ) + Return the range represented by buf( and )buf. + :eof? ( hdl -- f ) Whether ptr = )buf. diff --git a/fs/sys/io.fs b/fs/sys/io.fs @@ -71,6 +71,7 @@ extends IO struct[ MemIO dup >r V1 ptr ( src n dst ) swap move \ V2=n r> dup r> ( n n hdl ) to+ ptr ( written-n ) else nip rdrop then ; + : :range ( hdl -- a u ) dup buf( swap )buf over - ; : :eof? dup )buf swap ptr = ; : :rewind ( hdl -- ) dup buf( swap to ptr ; : :new ( a u -- hdl )