Edit this page Lock this page References to this page History of this page Home Page Recent Changes Upload file attachments Search Site Administration Help Guide

mfs

Use the mfs functions to access objects in the mfs directory.
NOTE All mfs commands must be inside a transaction { } block

scan

Return a list of the FSID's in a particular directory. For example:
set files [mfs scan "/Recording/History" -count 50]

This would retrieve a list of files in the /Recording/History directory. Each file is, itself, a list conatining the FSID, FileName, and FileType.
You can specify -count [maxCount] and -start [firstFile]

scancount

See how many records scan would return without a -count limit
set cnt [mfs scancount "/Recording/History"]

find

Return the FSID, FileType list specified by a given path
set fileInfo [mfs find /Setup]
set fsid [lindex $fileInfo 0]


size

Return the size of an FSID
set fileSize [mfs size $fsid]

streamsize

Return the streamsize of an FSID
set streamSize [mfs streamsize $fsid]

moddate

Return the modification date of an FSID
set moddate [mfs moddate $fsid]

allocate

put

get

getpart


Example code using features of mfs


#!/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
}


Even better, check out the function mls in fsdir.tcl in /tvbin/tcl/tv.