Posted to tcl by kevin_walzer at Wed Mar 30 14:28:34 GMT 2011view raw

  1. #run search for non-root directories, uses tclfilesearch package and regexes for search directory
  2. proc searchFiles {} {
  3.  
  4. global searchterm searchdir status findtool newlist listlength searchrunning
  5.  
  6. set searchrunning 1
  7.  
  8. clearFiles
  9. showProgress
  10.  
  11. tsv::set application searchterm $searchterm
  12. tsv::set application searchdir $searchdir
  13.  
  14. set searchthread [thread::create {
  15.  
  16. proc dirSearchThreadCmd {} {
  17. package require tclfilesearch
  18.  
  19. puts "running search"
  20.  
  21. set mysearch [tclfilesearch::filesearch [tsv::get application searchterm] /]
  22. set searchdir [tsv::get application searchdir]
  23.  
  24. if {[llength $mysearch] < 1} {
  25. set filelist {}
  26. } else {
  27.  
  28. foreach item $mysearch {
  29. if {[regexp ^$searchdir $item] && ![file isdir $item] } {
  30. lappend filelist $item
  31. }
  32. }
  33. }
  34. tsv::set application filelist $filelist
  35.  
  36. }
  37.  
  38.  
  39. thread::wait
  40. }]
  41. thread::send -async $searchthread dirSearchThreadCmd [tsv::set application filelist]
  42. # thread::send $searchthread $script [tsv::set application filelist]
  43.  
  44. vwait [tsv::set application filelist]
  45.  
  46. foreach item [ tsv::get application filelist] {
  47.  
  48. set filename [file tail $item]
  49. set filedir [file dirname $item]
  50. set modtime [ clock format [file mtime $item] -format "%m-%d-%Y %H:%M:%S"]
  51. set filesize [formatSize [file size $item]]
  52. set newlist [list $filename $filedir $modtime $filesize]
  53. lappend newlist
  54. .bottom.listframe.listbox insert end $newlist
  55.  
  56. .bottom.listframe.listbox cellconfigure end,0 -image [ tkmacicon::retrieveicon [file join a b $filedir $filename] 16 16 ]
  57. .bottom.listframe.listbox cellconfigure end,1 -image [ tkmacicon::retrieveicon $filedir 16 16 ]
  58. }
  59.  
  60.  
  61. thread::release $searchthread
  62.  
  63. getListLength
  64. updateExtMenu
  65. endProgress
  66. searchNotify
  67. set searchrunning 0
  68. }
  69.