add ts iterate

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1833 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2014-04-03 20:21:40 +00:00
parent e0ac834c78
commit 5f473c9e72
3 changed files with 29 additions and 32 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 1.0.10-5
Version: 1.0.10-6
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.10),mongoose(>=3.0.11),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.05),ffmpeg,id3v2,multienv(>=1.6)

View File

@ -3,7 +3,8 @@
source /mod/webif/lib/setup
require system.class ts.class
proc do_shrink {ts} {
ts iterate [lambda {ts} {
#puts " [$ts get file]"
if {[$ts flag "Shrunk"]} { return }
set file [file rootname [$ts get file]]
@ -26,34 +27,5 @@ proc do_shrink {ts} {
puts " Flagging $file as shrunk..."
$ts set_shrunk
}
}
proc entries {dir callback} {
foreach entry [readdir -nocomplain $dir] {
if {![string match {*.ts} $entry} continue
if {[catch {set ts [ts fetch "$dir/$entry"]}]} continue
if {$ts == 0} continue
$callback $ts
}
}
proc scan {dir} {
puts "Scanning $dir..."
file stat "$dir/" st
if {$st(dev) != $::rootdev} { return }
entries $dir do_shrink
foreach entry [readdir -nocomplain $dir] {
if {[file isdirectory "$dir/$entry"]} {
scan "$dir/$entry"
}
}
}
set root [system mediaroot]
file stat "$root/" rootstat
set rootdev $rootstat(dev)
scan $root
}] 1

View File

@ -392,3 +392,28 @@ proc {ts resetnew} {dir} {
close $fd
}
proc {ts iterate} {callback {verbose 0} {dir ""}} {{rootdev 0}} {
require system.class
if {$dir eq ""} {
set dir [system mediaroot]
file stat "$dir/" rootstat
set rootdev $rootstat(dev)
}
if {$verbose} { puts "Scanning directory ($dir)" }
file stat "$dir/" st
if {$st(dev) != $rootdev} return
foreach entry [readdir -nocomplain $dir] {
if {[file isdirectory "$dir/$entry"]} {
ts iterate $callback $verbose "$dir/$entry"
continue
}
if {![string match {*.ts} $entry]} continue
if {[catch {set ts [ts fetch "$dir/$entry"]}]} continue
if {$ts == 0} continue
$callback $ts
}
}