2f570f6ea0
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1425 2a923420-c742-0410-a762-8d5b09965624
50 lines
1.1 KiB
Plaintext
50 lines
1.1 KiB
Plaintext
|
|
proc {file copy} {{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/cp $source $target
|
|
} on error {msg opts} {
|
|
incr opts(-level)
|
|
return {*}$opts $msg
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
local proc file {cmd args} {
|
|
switch $cmd {
|
|
"rename" { tailcall {file rename} {*}$args }
|
|
"copy" { tailcall {file copy} {*}$args }
|
|
default { tailcall upcall file $cmd {*}$args }
|
|
}
|
|
}
|
|
|