ae607a6071
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@676 2a923420-c742-0410-a762-8d5b09965624
98 lines
1.9 KiB
Plaintext
Executable File
98 lines
1.9 KiB
Plaintext
Executable File
#!/mod/bin/jimsh
|
|
|
|
package require cgi
|
|
source /mod/var/mongoose/lib/setup
|
|
require ts.class pretty_size system.class tdelete
|
|
|
|
puts "Content-Type: text/html\r\n"
|
|
|
|
cgi_input
|
|
#cgi_dump
|
|
|
|
set dir [cgi_get dir]
|
|
|
|
#puts "DIR: ($dir)"
|
|
|
|
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
|
|
}
|
|
|
|
proc touch {file} {
|
|
exec /mod/bin/busybox/touch $file
|
|
}
|
|
|
|
puts "<div id=deleting class=blood><img src=/img/loading.gif>Deleting...</div>"
|
|
puts "<ul style=\"list-style-type: square\">"
|
|
foreach file [cgi_get files] {
|
|
puts -nonewline "<li>\"$file\"..."
|
|
regsub -all {([\\["$])} $dir {\\\1} dir
|
|
if {![string match "$dir/*" $file]} {
|
|
puts "Error - outside directory."
|
|
continue
|
|
}
|
|
|
|
if {[string first $dustbin $file] > -1} {
|
|
set ldustbin ""
|
|
} else {
|
|
set ldustbin $dustbin
|
|
}
|
|
|
|
set done 0
|
|
if {[file isdirectory $file]} {
|
|
puts -nonewline "Directory..."
|
|
if {$ldustbin ne ""} {
|
|
set ndir "[bindir $file]/[file tail $file]"
|
|
while {[file isdirectory $ndir]} { append ndir "_" }
|
|
file rename $file $ndir
|
|
touch $ndir
|
|
} else {
|
|
tdelete $file
|
|
}
|
|
puts -nonewline "Done..."
|
|
set done 1
|
|
} elseif {[string match {*.ts} $file]} {
|
|
set ts [ts fetch $file]
|
|
|
|
# Check TS validity
|
|
if {![catch {$ts get file}]} {
|
|
if {$ldustbin ne ""} {
|
|
$ts move [bindir $file] 1
|
|
} else {
|
|
if {[$ts delete]} {
|
|
puts "Successfully deleted $file."
|
|
} else {
|
|
puts "Problem deleting $file, [$ts get error]"
|
|
}
|
|
}
|
|
set done 1
|
|
}
|
|
# else treat as normal file.
|
|
}
|
|
|
|
if {!$done} {
|
|
if {$ldustbin ne ""} {
|
|
set nfile "[bindir $file]/[file tail $file]"
|
|
file rename $file $nfile
|
|
touch $nfile
|
|
} else {
|
|
tdelete $file
|
|
}
|
|
catch {file delete "[file rootname $file].hmi"}
|
|
puts -nonewline "Done..."
|
|
}
|
|
|
|
puts "</li>"
|
|
}
|
|
puts "</ul>"
|
|
|