FindFileApplication.st
changeset 15217 d815d45f3c53
parent 15214 f00b3fcd0a60
child 15566 184cea584be5
child 15660 252c9daa66e0
--- a/FindFileApplication.st	Sat Feb 07 15:21:50 2015 +0100
+++ b/FindFileApplication.st	Sat Feb 07 15:22:03 2015 +0100
@@ -1337,6 +1337,11 @@
     notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents 
     sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory
 
+    "the main workhorse for searching files.
+     Creates optimized search blocks, depending on how we search,
+     and passes these to the recursive directory walker.
+     (got too big, and may need some splitting/refactoring"
+
     |dir lines contentsToCompare resultList inStream
      doesFileMatch contentsString notContentsString check checkNot 
      grepCommand nameMatch nameExcludedMatch realNameMatch 
@@ -1711,6 +1716,8 @@
         ].
     ].
 
+    filesSearchedCount := 0.
+
     self 
         doFindFileNamed:namePatterns 
         directories:searchDirectories
@@ -1722,16 +1729,24 @@
 !
 
 doFindFileNamed:namePatterns directories:searchDirectories nameMatch:nameMatch contentsMatch:doesFileMatch in:aDirectory
-    |dir subDirs list directoryContents|
+    "the recursive walker. Searches for files matching namematch-block,
+     and contents matching doesFileMatch-block"
+
+    |dir subDirs list directoryContents updateInfo|
 
     dir := aDirectory asFilename.
 
+    updateInfo :=
+        [
+            self 
+                changeInformationTo:('%1 found - searching %2' 
+                                        bindWith:resultList size
+                                        with:((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1))) 
+                toTab:false.
+        ].
+
     self window shown ifTrue:[
-        self 
-            changeInformationTo:('%1 found - searching %2' 
-                                    bindWith:resultList size
-                                    with:((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1))) 
-            toTab:false.
+        updateInfo value.
     ].
     list := self resultList.
 
@@ -1760,13 +1775,10 @@
         ].
         (searchDirectories or:[isDirectory not]) ifTrue:[
             (nameMatch value:fn) ifTrue:[
+                filesSearchedCount := (filesSearchedCount ? 0) + 1.
                 (isDirectory or:[ doesFileMatch value:f ])
                 ifTrue:[
-                    self 
-                        changeInformationTo:('%1 found - searching %2' 
-                                                bindWith:resultList size
-                                                with:((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1))) 
-                        toTab:false.
+                    updateInfo value.
                     list add:(f asString).
                 ]
             ]
@@ -1907,10 +1919,10 @@
 !FindFileApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.116 2015-02-07 13:39:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.117 2015-02-07 14:22:03 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.116 2015-02-07 13:39:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.117 2015-02-07 14:22:03 cg Exp $'
 ! !