Refining file handling.

This commit is contained in:
Brad Nelson
2022-09-05 18:31:44 -07:00
parent 8cd205a9a5
commit 0dbe262abf
4 changed files with 20 additions and 15 deletions

View File

@ -18,15 +18,6 @@
r> close-file drop
;
: cat ( "path" -- )
bl parse r/o bin open-file throw { fh }
begin
here 80 fh read-file throw
dup 0= if drop fh close-file throw exit then
here swap type
again
;
: cp ( "src" "dst" -- )
bl parse r/o bin open-file throw { inf }
bl parse w/o bin create-file throw { outf }
@ -46,6 +37,22 @@
close-file throw
;
internals definitions
: cremit ( ch -- ) dup nl = if drop cr else emit then ;
: crtype ( a n -- ) for aft dup c@ cremit 1+ then next drop ;
forth definitions internals
: cat ( "path" -- )
bl parse r/o bin open-file throw { fh }
begin
here 80 fh read-file throw
dup 0= if drop fh close-file throw exit then
here swap crtype
again
;
internals definitions
( Leave some room for growth of starting system. )
0 value saving-base