2011-06-22 23:36:30 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2012-01-10 19:51:45 +00:00
|
|
|
source /mod/var/mongoose/lib/setup
|
2012-01-13 21:23:03 +00:00
|
|
|
require ts.class system.class tdelete
|
2011-06-22 23:36:30 +00:00
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
|
|
|
set file [dict get $_cgi file]
|
|
|
|
set type [dict get $_cgi type]
|
|
|
|
|
2012-01-10 19:51:45 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-01-14 00:29:44 +00:00
|
|
|
# Handle deletions from the bin.
|
|
|
|
if {[string first $dustbin $file] > -1} { set dustbin "" }
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
if {$type eq "ts"} {
|
|
|
|
set ts [ts fetch $file]
|
2012-01-10 19:51:45 +00:00
|
|
|
if {$dustbin ne ""} {
|
|
|
|
$ts move [bindir $file]
|
2011-06-22 23:36:30 +00:00
|
|
|
} else {
|
2012-01-10 19:51:45 +00:00
|
|
|
if {[$ts delete]} {
|
|
|
|
puts "Successfully deleted $file."
|
|
|
|
} else {
|
|
|
|
puts "Problem deleting $file, [$ts get error]"
|
|
|
|
}
|
2011-06-22 23:36:30 +00:00
|
|
|
}
|
|
|
|
exit
|
2011-12-09 10:11:41 +00:00
|
|
|
} elseif {$type eq "dir"} {
|
|
|
|
puts -nonewline "Directory..."
|
2012-01-10 19:51:45 +00:00
|
|
|
if {$dustbin ne ""} {
|
|
|
|
set ndir "[bindir $file]/[file tail $file]"
|
|
|
|
while {[file isdirectory $ndir]} { append ndir "_" }
|
|
|
|
file rename $file $ndir
|
|
|
|
} else {
|
2012-01-13 21:23:03 +00:00
|
|
|
tdelete $file
|
2012-01-10 19:51:45 +00:00
|
|
|
}
|
2011-12-09 10:11:41 +00:00
|
|
|
puts -nonewline "Done..."
|
|
|
|
} else {
|
2012-01-10 19:51:45 +00:00
|
|
|
if {$dustbin ne ""} {
|
|
|
|
file rename $file "[bindir $file]/[file tail $file]"
|
|
|
|
} else {
|
2012-01-13 21:23:03 +00:00
|
|
|
tdelete $file
|
2012-01-10 19:51:45 +00:00
|
|
|
}
|
|
|
|
catch {file delete "[file rootname $file].hmi"}
|
|
|
|
|
2011-12-09 10:11:41 +00:00
|
|
|
puts "Successfully deleted $file."
|
2011-06-22 23:36:30 +00:00
|
|
|
}
|
|
|
|
|