Refining file handling.
This commit is contained in:
@ -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
|
||||
|
||||
@ -409,11 +409,11 @@ e: check-snapshots
|
||||
out: remember
|
||||
out: restore
|
||||
out: save
|
||||
out: cat
|
||||
out: touch
|
||||
out: rm
|
||||
out: mv
|
||||
out: cp
|
||||
out: cat
|
||||
out: dump-file
|
||||
;e
|
||||
|
||||
|
||||
@ -39,9 +39,6 @@ start-size value capacity
|
||||
: down ( n -- n ) begin dup length < over text + c@ nl <> and while 1+ repeat 1+ length min ;
|
||||
: ndown ( n -- n ) 10 for down next ;
|
||||
|
||||
: cremit ( ch -- ) dup nl = if drop cr else emit then ;
|
||||
: crtype ( a n -- ) for aft dup c@ cremit 1+ then next drop ;
|
||||
|
||||
: update
|
||||
caret nup dup 0<> if 1+ 1+ then { before }
|
||||
before ndown ndown { after }
|
||||
|
||||
Reference in New Issue
Block a user