#!/tvbin/tivosh
## mfsDir.tcl
## Run with a list of paths to show a directory of each path
## e.g., mfs.tcl /Recording/History
proc mfsDir {mfsdir} {
set db [dbopen]
transaction {
set dirInfo [mfs find $mfsdir]
set dirFSID [lindex $dirInfo 0]
set files [mfs scan $mfsdir -count 50]
set dirSize [mfs size $dirFSID]
}
puts "Directory: $mfsdir (fsid=$dirFSID, size=$dirSize)"
while { [llength $files] > 0 } {
foreach rec $files {
set fsid [lindex $rec 0]
set name [lindex $rec 1]
set type [lindex $rec 2]
transaction {
set filesize [mfs size $fsid]
}
puts -nonewline "fsid=[format "%6d" $fsid], "
puts -nonewline "size=[format "%6d" $filesize], "
puts "($type:$name)"
}
# and grab the next 50 television shows
set lastIndex [lindex [lindex $files end] 1]
transaction {
set files [mfs scan $mfsdir -start $lastIndex -count 50]
}
if { $lastIndex == [lindex [lindex $files 0] 1] } {
set files [lrange $files 1 end]
}
}
}
foreach path $argv {
mfsDir $path
}