webif/var/mongoose/cgi-bin/browse/delete.jim
hummypkg ce2dfa8338 update delete system
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@657 2a923420-c742-0410-a762-8d5b09965624
2012-01-13 21:23:03 +00:00

63 lines
1.2 KiB
Plaintext
Executable File

#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require ts.class system.class tdelete
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
set file [dict get $_cgi file]
set type [dict get $_cgi type]
if {[system pkginst undelete]} {
set dustbin [system dustbin]
} else {
set dustbin ""
}
proc bindir {file} {
global dustbin
set dir [file dirname $file]
regsub "^[system mediaroot]" $dir $dustbin dir
system mkdir_p $dir
return $dir
}
if {$type eq "ts"} {
set ts [ts fetch $file]
if {$dustbin ne ""} {
$ts move [bindir $file]
} else {
if {[$ts delete]} {
puts "Successfully deleted $file."
} else {
puts "Problem deleting $file, [$ts get error]"
}
}
exit
} elseif {$type eq "dir"} {
puts -nonewline "Directory..."
if {$dustbin ne ""} {
set ndir "[bindir $file]/[file tail $file]"
while {[file isdirectory $ndir]} { append ndir "_" }
file rename $file $ndir
} else {
tdelete $file
}
puts -nonewline "Done..."
} else {
if {$dustbin ne ""} {
file rename $file "[bindir $file]/[file tail $file]"
} else {
tdelete $file
}
catch {file delete "[file rootname $file].hmi"}
puts "Successfully deleted $file."
}