diff --git a/var/mongoose/lib/filerename b/var/mongoose/lib/filerename new file mode 100644 index 0000000..227d572 --- /dev/null +++ b/var/mongoose/lib/filerename @@ -0,0 +1,21 @@ + +proc {file rename} {{force {}} source target} { + try { + if {$force ni {{} -force}} { + error "bad option \"$force\": should be -force" + } + + if {![file exists $source]} { + error "source file does not exist." + } + + if {$force eq "" && [file exists $target]} { + error "error copying \"$source\" to \"$target\": file already exists" + } + exec /mod/bin/busybox/mv $source $target + } on error {msg opts} { + incr opts(-level) + return {*}$opts $msg + } +} + diff --git a/var/mongoose/lib/setup b/var/mongoose/lib/setup index 11c43ca..b4112a0 100644 --- a/var/mongoose/lib/setup +++ b/var/mongoose/lib/setup @@ -45,5 +45,9 @@ if {![exists -proc require]} { # largefile safe. require filecopy + + # and {file rename} with one that supports cross-filesystem moves. + + require filerename }