duskos

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

commit ee265fc4cd91f92326db016cb46577163acc9c08
parent eac0ad4b5e4ec27c53d6084ab12561c020ac7184
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Mon, 18 Jul 2022 21:16:49 -0400

fs/fat: replace fatputc with fatwritebuf

Diffstat:
Mfs/fs/fat.fs | 14+++++++-------
Mfs/tests/fs/fat.fs | 2+-
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/fs/fat.fs b/fs/fs/fat.fs @@ -97,10 +97,10 @@ current to fatflush r> FCUR_size ClusterSize / ?dup if >r begin ( cluster ) FAT@+ next then ( cluster ) drop ; -\ Write c to fcursor and advance the position by one, growing the file if -\ needed. -: fatputc ( c fcursor -- ) - dup >r FCUR_pos dup 1+ r@ fatgrow ( c newpos R:fcursor ) - r@ fatseek - r@ FCUR_flags 2 or ( dirty ) r@ FCUR_flags! ( c R:fcursor ) - r@ FCUR_bufpos c! 1 r> FCUR_pos+ ; +: fatwritebuf ( buf n fcursor -- n ) + dup >r FCUR_pos over + r@ fatgrow ( src n ) + r@ FCUR_pos r@ fatseek + r@ FCUR_flags 2 or ( dirty ) r@ FCUR_flags! + r@ FCUR_)buf r@ FCUR_bufpos - ( src n nmax ) + min ( src n ) r> FCUR_bufpos swap ( src dst n ) + dup >r move r> ( n ) ; diff --git a/fs/tests/fs/fat.fs b/fs/tests/fs/fat.fs @@ -32,6 +32,6 @@ S" /newfile" fatfindpath # \ found! \ let's try writing to it S" /newfile" fatfindpath openfile ( fc ) dup FCUR_cluster0 0 #eq \ no cluster allocated yet -'4' over fatputc '2' over fatputc fclose +dup S" 42" c@+ rot fatwritebuf 2 #eq ( fc ) fclose f<< /newfile 42 #eq testend