diff --git a/webif/html/browse/index.jim b/webif/html/browse/index.jim index 762a1c7c..669831e7 100755 --- a/webif/html/browse/index.jim +++ b/webif/html/browse/index.jim @@ -319,10 +319,39 @@ proc s_time {a b} { return 0 } +proc s_size {a b} { + global dir + + set a "$dir/$a" + set b "$dir/$b" + + set ad [file isdirectory $a] + set bd [file isdirectory $b] + + if {$ad && !$bd} { return -1 } + if {$bd && !$ad} { return 1 } + if {$ad && $bd} { + if {$a < $b} { return -1 } + if {$a > $b} { return 1 } + return 0 + } + + if {[catch {file stat $a l}]} { return 0} + set as $l(size) + if {[catch {file stat $b l}]} { return 0} + set bs $l(size) + + if {$as < $bs} { return -1 } + if {$as > $bs} { return 1 } + return 0 +} + set files [readdir -nocomplain $dir] switch $order { 1 { set files [lsort -command s_time $files] } 2 { set files [lreverse [lsort -command s_time $files]] } + 3 { set files [lsort -command s_size $files] } + 4 { set files [lreverse [lsort -command s_size $files]] } default { set files [lsort -nocase $files] } } @@ -337,19 +366,23 @@ Directories: $dircount, Files: $filecount # Sort icons puts "