# ACTIVESTATE TEAPOT-PKG BEGIN TM -*- tcl -*- # -- Tcl Module # @@ Meta Begin # Package vfs::cookfs::tcl::optimize 1.3 # Meta as::author {Wojciech Kocjan} # Meta as::build::date 2014-02-10 # Meta as::origin http://sf.net/projects/cookit # Meta category Virtual filesystems # Meta description Support for package vfs::cookfs, structure # Meta description optimization. # Meta platform tcl # Meta require {Tcl 8.4} # Meta subject {virtual filesystem} # Meta summary vfs::cookfs support, optimization # @@ Meta End # ACTIVESTATE TEAPOT-PKG BEGIN REQUIREMENTS package require Tcl 8.4 # ACTIVESTATE TEAPOT-PKG END REQUIREMENTS # ACTIVESTATE TEAPOT-PKG BEGIN DECLARE package provide vfs::cookfs::tcl::optimize 1.3 # ACTIVESTATE TEAPOT-PKG END DECLARE # ACTIVESTATE TEAPOT-PKG END TM # cookfs::tcl::optimize -- # # Optimize file list for minimal reading operations # # (c) 2010 Wojciech Kocjan, Pawel Salawa namespace eval cookfs {} proc cookfs::optimizelist {fsid base filelist} { upvar #0 $fsid fs set largefiles {} set smallfiles {} foreach file $filelist { set path [file join $base $file] set chunklist [lindex [$fs(index) get $path] 2] if {[llength $chunklist] > 3} { lappend largefiles $file } else { lappend atpage([lindex $chunklist 0]) $file } } foreach idx [lsort -integer [array names atpage]] { set smallfiles [concat $smallfiles $atpage($idx)] } return [concat $smallfiles $largefiles] } package provide vfs::cookfs::tcl::optimize 1.3