Posted to tcl by kevin_walzer at Wed Mar 30 14:28:34 GMT 2011view raw
- #run search for non-root directories, uses tclfilesearch package and regexes for search directory
- proc searchFiles {} {
- global searchterm searchdir status findtool newlist listlength searchrunning
- set searchrunning 1
- clearFiles
- showProgress
- tsv::set application searchterm $searchterm
- tsv::set application searchdir $searchdir
- set searchthread [thread::create {
- proc dirSearchThreadCmd {} {
- package require tclfilesearch
- puts "running search"
- set mysearch [tclfilesearch::filesearch [tsv::get application searchterm] /]
- set searchdir [tsv::get application searchdir]
- if {[llength $mysearch] < 1} {
- set filelist {}
- } else {
- foreach item $mysearch {
- if {[regexp ^$searchdir $item] && ![file isdir $item] } {
- lappend filelist $item
- }
- }
- }
- tsv::set application filelist $filelist
- }
- thread::wait
- }]
- thread::send -async $searchthread dirSearchThreadCmd [tsv::set application filelist]
- # thread::send $searchthread $script [tsv::set application filelist]
- vwait [tsv::set application filelist]
- foreach item [ tsv::get application filelist] {
- set filename [file tail $item]
- set filedir [file dirname $item]
- set modtime [ clock format [file mtime $item] -format "%m-%d-%Y %H:%M:%S"]
- set filesize [formatSize [file size $item]]
- set newlist [list $filename $filedir $modtime $filesize]
- lappend newlist
- .bottom.listframe.listbox insert end $newlist
- .bottom.listframe.listbox cellconfigure end,0 -image [ tkmacicon::retrieveicon [file join a b $filedir $filename] 16 16 ]
- .bottom.listframe.listbox cellconfigure end,1 -image [ tkmacicon::retrieveicon $filedir 16 16 ]
- }
- thread::release $searchthread
- getListLength
- updateExtMenu
- endProgress
- searchNotify
- set searchrunning 0
- }