#!/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 } # Handle deletions from the bin. if {[string first $dustbin $file] > -1} { set dustbin "" } 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." }