commit 9370014eb52a8ed33cb00d2643b7fcddbff06009 parent 4717adf3449d385b855ef0e7796a12a377c0475f Author: Virgil Dupras <hsoft@hardcoded.net> Date: Sat, 4 Feb 2023 11:56:26 -0500 sys/file: refactor Path :copyfile Diffstat:
M | fs/sys/file.fs | | | 21 | ++++++++++----------- |
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/fs/sys/file.fs b/fs/sys/file.fs @@ -92,24 +92,23 @@ struct[ Path \ dst is the *parent* of where the source element will be - 0 value _dstfs - 0 value _dstid + create _dst SZ allot + create _src SZ allot : _ ( id fs -- ) - >r >r \ V1=srcfs V2=srcid - V2 V1 Filesystem :info dup FSInfo name stype nl> + _src to fs _src to id + _src :info dup FSInfo name stype nl> dup FSInfo dir? if ( info ) - _dstid swap FSInfo name _dstfs Filesystem :?newdir ( id ) - to@! _dstid ( oldid ) - ['] _ r> r> ( oldid w srcid srcfs ) Filesystem :iter ( oldid ) to _dstid + _dst id swap FSInfo name _dst fs Filesystem :?newdir ( id ) + to@! _dst id ( oldid ) + ['] _ _src :iter ( oldid ) to _dst id else ( info ) - _dstid swap FSInfo name _dstfs Filesystem :?newfile ( id ) - _dstfs Filesystem :open ( dstfile ) r> r> Filesystem :open ( srcfile ) + _dst id swap FSInfo name _dst fs Filesystem :?newfile ( id ) + _dst fs Filesystem :open ( dstfile ) _src :open ( srcfile ) _copyfile then ; \ For now, this method has to be called on a freshly created directory as \ "dst". We assume that no destination file or directory exist in dst. - : :copydir ( dst self -- ) - over id to _dstid swap fs to _dstfs ( self ) ['] _ swap :iter ; + : :copydir ( dst self -- ) swap _dst SZ move ['] _ swap :iter ; : _ ( id fs -- ) Filesystem :info FSInfo name stype nl> ; : :listdir ( self -- ) ['] _ swap :iter ;