author | Claus Gittinger <cg@exept.de> |
Mon, 20 Feb 2006 11:17:30 +0100 | |
changeset 6583 | 2652ac4ca0ee |
parent 6482 | 00207f456339 |
child 6633 | 6843fedf7516 |
permissions | -rw-r--r-- |
5140 | 1 |
" |
2 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
3892 | 13 |
"{ Package: 'stx:libtool' }" |
14 |
||
15 |
AbstractFileApplicationNoteBookComponent subclass:#FindFileApplication |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
16 |
instanceVariableNames:'searchDirectories searchDirectoryHolder notSearchForSameContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
17 |
namePatternHolder ignoreCaseInName contentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
18 |
ignoreCaseInContents notContentsPatternHolder |
5723 | 19 |
ignoreCaseInNotContents sameContentsAsHolder findFileView |
20 |
searchResultTable resultList enableStop enableSearch stopSignal |
|
21 |
accessLock searchTask expanded searchRecursively selectionHolder |
|
22 |
hasListEntries targetApplication useLocate useGrep |
|
5859 | 23 |
rememberInCache searchOnlyInCache searchForSameContents |
6107 | 24 |
matchedFilesList shownListHolder contentsInfoCache |
6330 | 25 |
contentsInfoCacheAccessLock autoSelectInBrowserHolder |
26 |
fileSizeOperatorHolder fileSizeHolder enableFileSizeFilter |
|
27 |
fileSizeUnitHolder' |
|
6442 | 28 |
classVariableNames:'ContentsInfoCache ContentsInfoCacheAccessLock LastRememberInCache |
29 |
LastSearchIgnoredCaseInContents LastSearchIgnoredCaseInFilename' |
|
3892 | 30 |
poolDictionaries:'' |
31 |
category:'Interface-Tools-File' |
|
32 |
! |
|
33 |
||
5140 | 34 |
!FindFileApplication class methodsFor:'documentation'! |
35 |
||
36 |
copyright |
|
37 |
" |
|
38 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
39 |
All Rights Reserved |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
" |
|
48 |
! ! |
|
3892 | 49 |
|
50 |
!FindFileApplication class methodsFor:'instance creation'! |
|
51 |
||
52 |
open |
|
5723 | 53 |
^ self openInDirectory:(Filename currentDirectory) |
3892 | 54 |
|
5723 | 55 |
" |
56 |
self open |
|
57 |
" |
|
58 |
! |
|
59 |
||
60 |
openInDirectory:aFilename |
|
61 |
^ self openOnFileName:(aFilename asFilename asAbsoluteFilename) |
|
62 |
||
63 |
" |
|
64 |
self openInDirectory:'/etc' |
|
65 |
" |
|
3892 | 66 |
! |
67 |
||
68 |
openOnFileName:aFileName |
|
5723 | 69 |
^ self openOnFileName:aFileName for:nil |
70 |
! |
|
71 |
||
72 |
openOnFileName:aFileName for:aTargetApplicationOrNil |
|
3892 | 73 |
|
74 |
| instance builder| |
|
75 |
||
76 |
builder := super open. |
|
77 |
instance := builder application. |
|
3983 | 78 |
instance item:(DirectoryContentsBrowser itemClass fileName:aFileName). |
5723 | 79 |
aTargetApplicationOrNil notNil ifTrue:[ |
80 |
instance targetApplication:aTargetApplicationOrNil. |
|
81 |
]. |
|
3892 | 82 |
^ builder |
83 |
! ! |
|
84 |
||
85 |
!FindFileApplication class methodsFor:'defaults'! |
|
86 |
||
87 |
tabStringFor:aApplicationType |
|
88 |
||
5774 | 89 |
^ 'Find File In:' |
3892 | 90 |
! ! |
91 |
||
92 |
!FindFileApplication class methodsFor:'interface specs'! |
|
93 |
||
94 |
windowSpec |
|
95 |
"This resource specification was automatically generated |
|
96 |
by the UIPainter of ST/X." |
|
97 |
||
98 |
"Do not manually edit this!! If it is corrupted, |
|
99 |
the UIPainter may not be able to read the specification." |
|
100 |
||
101 |
" |
|
102 |
UIPainter new openOnClass:FindFileApplication andSelector:#windowSpec |
|
103 |
FindFileApplication new openInterface:#windowSpec |
|
104 |
FindFileApplication open |
|
105 |
" |
|
106 |
||
107 |
<resource: #canvas> |
|
108 |
||
109 |
^ |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
110 |
#(FullSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
111 |
name: windowSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
112 |
window: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
113 |
(WindowSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
114 |
label: 'File Search' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
115 |
name: 'File Search' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
116 |
min: (Point 377 131) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
117 |
max: (Point 1280 1024) |
5850 | 118 |
bounds: (Rectangle 0 0 758 512) |
3892 | 119 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
120 |
component: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
121 |
(SpecCollection |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
122 |
collection: ( |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
123 |
(MenuPanelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
124 |
name: 'ToolBar1' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
125 |
layout: (LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
126 |
level: 0 |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
127 |
menu: searchMenu |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
128 |
textDefault: true |
3892 | 129 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
130 |
(ViewSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
131 |
name: 'Box1' |
6330 | 132 |
layout: (LayoutFrame 0 0.0 32 0 0 1.0 180 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
133 |
component: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
134 |
(SpecCollection |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
135 |
collection: ( |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
136 |
(LabelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
137 |
label: 'Directory:' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
138 |
name: 'DirectoryLabel' |
5557 | 139 |
layout: (LayoutFrame 2 0 7 0 154 0 24 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
140 |
translateLabel: true |
5557 | 141 |
adjust: right |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
142 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
143 |
(FilenameInputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
144 |
name: 'DirectoryEntryField' |
5603 | 145 |
layout: (LayoutFrame 156 0 4 0 -315 1 24 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
146 |
model: searchDirectoryHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
147 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
148 |
acceptOnPointerLeave: false |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
149 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
150 |
(CheckBoxSpec |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
151 |
label: 'Use ''locate'' Cmd' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
152 |
name: 'UseLocateCheckBox' |
5851 | 153 |
layout: (LayoutFrame -309 1 5 0 -167 1 28 0) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
154 |
visibilityChannel: canUseLocate |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
155 |
tabable: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
156 |
model: useLocate |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
157 |
translateLabel: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
158 |
) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
159 |
(CheckBoxSpec |
5557 | 160 |
label: 'Recursive' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
161 |
name: 'RecursiveSearchCheckBox' |
5851 | 162 |
layout: (LayoutFrame -169 1 5 0 -4 1 28 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
163 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
164 |
model: searchRecursively |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
165 |
translateLabel: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
166 |
) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
167 |
(LabelSpec |
5603 | 168 |
label: 'Search Files Named:' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
169 |
name: 'FileNameLabel' |
5723 | 170 |
layout: (LayoutFrame 2 0 31 0 154 0 48 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
171 |
translateLabel: true |
5557 | 172 |
adjust: right |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
173 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
174 |
(InputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
175 |
name: 'FileNameEntryField' |
5603 | 176 |
layout: (LayoutFrame 156 0 28 0 -315 1 48 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
177 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
178 |
model: namePatternHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
179 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
180 |
acceptOnLeave: false |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
181 |
acceptOnPointerLeave: false |
3892 | 182 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
183 |
(CheckBoxSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
184 |
label: 'Directories' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
185 |
name: 'SearchDirectoriesCheckBox' |
5851 | 186 |
layout: (LayoutFrame -309 1 29 0 -167 1 52 0) |
5774 | 187 |
enableChannel: notSearchForSameContents |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
188 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
189 |
model: searchDirectories |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
190 |
translateLabel: true |
3892 | 191 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
192 |
(CheckBoxSpec |
5603 | 193 |
label: 'Ignore Case' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
194 |
name: 'IgnoreCaseInNameCheckBox' |
5851 | 195 |
layout: (LayoutFrame -169 1 29 0 -4 1 52 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
196 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
197 |
model: ignoreCaseInName |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
198 |
translateLabel: true |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
199 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
200 |
(LabelSpec |
5557 | 201 |
label: 'Containing:' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
202 |
name: 'ContentsLabel' |
5557 | 203 |
layout: (LayoutFrame 2 0 55 0 154 0 72 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
204 |
translateLabel: true |
5557 | 205 |
adjust: right |
3892 | 206 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
207 |
(InputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
208 |
name: 'ContentsEntryField' |
5603 | 209 |
layout: (LayoutFrame 156 0 52 0 -315 1 72 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
210 |
enableChannel: notSearchForSameContents |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
211 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
212 |
model: contentsPatternHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
213 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
214 |
acceptOnPointerLeave: false |
3892 | 215 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
216 |
(CheckBoxSpec |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
217 |
label: 'Use ''grep'' Cmd' |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
218 |
name: 'UseGrepCheckBox' |
5851 | 219 |
layout: (LayoutFrame -309 1 53 0 -167 1 76 0) |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
220 |
visibilityChannel: canUseGrep |
5743 | 221 |
enableChannel: notSearchForSameContents |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
222 |
tabable: true |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
223 |
model: useGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
224 |
translateLabel: true |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
225 |
) |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
226 |
(CheckBoxSpec |
5603 | 227 |
label: 'Ignore Case' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
228 |
name: 'IgnoreCaseInContentsCheckBox' |
5851 | 229 |
layout: (LayoutFrame -169 1 53 0 -4 1 76 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
230 |
enableChannel: notSearchForSameContents |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
231 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
232 |
model: ignoreCaseInContents |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
233 |
translateLabel: true |
3892 | 234 |
) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
235 |
(LabelSpec |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
236 |
label: 'Not Containing:' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
237 |
name: 'NotContentsLabel' |
5557 | 238 |
layout: (LayoutFrame 2 0 79 0 154 0 96 0) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
239 |
translateLabel: true |
5557 | 240 |
adjust: right |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
241 |
) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
242 |
(InputFieldSpec |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
243 |
name: 'NotContentsEntryField' |
5603 | 244 |
layout: (LayoutFrame 156 0 76 0 -315 1 96 0) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
245 |
enableChannel: notSearchForSameContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
246 |
tabable: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
247 |
model: notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
248 |
immediateAccept: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
249 |
acceptOnPointerLeave: false |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
250 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
251 |
(CheckBoxSpec |
5603 | 252 |
label: 'Ignore Case' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
253 |
name: 'IgnoreCaseInNotContentsCheckBox' |
5851 | 254 |
layout: (LayoutFrame -169 1 77 0 -4 1 100 0) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
255 |
enableChannel: notSearchForSameContents |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
256 |
tabable: true |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
257 |
model: ignoreCaseInNotContents |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
258 |
translateLabel: true |
3892 | 259 |
) |
5723 | 260 |
(LabelSpec |
261 |
label: 'Same Contents As:' |
|
262 |
name: 'SameContentsAsLabel' |
|
263 |
layout: (LayoutFrame 2 0 103 0 154 0 120 0) |
|
264 |
translateLabel: true |
|
265 |
adjust: right |
|
266 |
) |
|
267 |
(InputFieldSpec |
|
268 |
name: 'SameContentsAsEntryField' |
|
5743 | 269 |
layout: (LayoutFrame 156 0 100 0 -339 1 120 0) |
270 |
enableChannel: searchForSameContents |
|
5723 | 271 |
tabable: true |
272 |
model: sameContentsAsHolder |
|
273 |
immediateAccept: true |
|
274 |
acceptOnPointerLeave: false |
|
275 |
) |
|
276 |
(CheckBoxSpec |
|
277 |
label: 'Cache Info' |
|
278 |
name: 'RememberInCacheCheckBox' |
|
5851 | 279 |
layout: (LayoutFrame -309 1 101 0 -167 1 124 0) |
5723 | 280 |
visibilityChannel: canUseGrep |
5743 | 281 |
enableChannel: searchForSameContents |
5723 | 282 |
tabable: true |
283 |
model: rememberInCache |
|
284 |
translateLabel: true |
|
285 |
) |
|
5743 | 286 |
(CheckToggleSpec |
287 |
name: 'EnableSameContentsCheckToggle' |
|
288 |
layout: (LayoutOrigin -334 1 104 0) |
|
289 |
model: searchForSameContents |
|
290 |
isTriggerOnDown: true |
|
291 |
showLamp: false |
|
292 |
lampColor: (Color 100.0 100.0 0.0) |
|
293 |
) |
|
5850 | 294 |
(ActionButtonSpec |
295 |
label: 'Clear Cache' |
|
296 |
name: 'ClearCacheButton' |
|
5851 | 297 |
layout: (LayoutFrame -169 1 101 0 -44 1 123 0) |
5850 | 298 |
translateLabel: true |
299 |
model: clearCache |
|
300 |
) |
|
6330 | 301 |
(LabelSpec |
302 |
label: 'File Size:' |
|
303 |
name: 'Label1' |
|
304 |
layout: (LayoutFrame 2 0 127 0 154 0 144 0) |
|
305 |
translateLabel: true |
|
306 |
adjust: right |
|
307 |
) |
|
308 |
(PopUpListSpec |
|
309 |
label: 'PopUp List' |
|
310 |
name: 'OperatorPopUpList' |
|
311 |
layout: (LayoutFrame 157 0 124 0 212 0 144 0) |
|
312 |
tabable: true |
|
313 |
model: fileSizeOperatorHolder |
|
314 |
enableChannel: enableFileSizeFilterAndNotSearchForSameContents |
|
315 |
menu: |
|
316 |
('>' |
|
317 |
'=' '!!=' |
|
318 |
'~' '<' |
|
319 |
) |
|
320 |
) |
|
321 |
(InputFieldSpec |
|
322 |
name: 'EntryField1' |
|
323 |
layout: (LayoutFrame 219 0 124 0 -430 1 144 0) |
|
324 |
enableChannel: enableFileSizeFilterAndNotSearchForSameContents |
|
325 |
tabable: true |
|
326 |
model: fileSizeHolder |
|
327 |
type: fileSize |
|
328 |
immediateAccept: true |
|
329 |
acceptOnPointerLeave: false |
|
330 |
) |
|
331 |
(CheckToggleSpec |
|
332 |
name: 'EnableSizeCheckToggle' |
|
333 |
layout: (LayoutOrigin -334 1 127 0) |
|
334 |
model: enableFileSizeFilter |
|
335 |
enableChannel: notSearchForSameContents |
|
336 |
isTriggerOnDown: true |
|
337 |
showLamp: false |
|
338 |
lampColor: (Color 100.0 100.0 0.0) |
|
339 |
) |
|
3892 | 340 |
) |
341 |
||
342 |
) |
|
343 |
) |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
344 |
(SequenceViewSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
345 |
name: 'List1' |
6330 | 346 |
layout: (LayoutFrame 0 0.0 180 0 0 1.0 0 1) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
347 |
model: selectionHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
348 |
menu: menu |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
349 |
hasHorizontalScrollBar: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
350 |
hasVerticalScrollBar: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
351 |
isMultiSelect: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
352 |
doubleClickSelector: fileDoubleClick: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
353 |
useIndex: true |
5864 | 354 |
sequenceList: shownListHolder |
3892 | 355 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
356 |
(ProgressIndicatorSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
357 |
name: 'ProgressIndicator1' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
358 |
layout: (LayoutFrame 125 0 11 0 231 0 21 0) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
359 |
visibilityChannel: enableStop |
6330 | 360 |
backgroundColor: (Color 0.0 66.999313344015 66.999313344015) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
361 |
showPercentage: false |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
362 |
isActivityIndicator: true |
4168 | 363 |
) |
3892 | 364 |
) |
365 |
||
366 |
) |
|
367 |
) |
|
6330 | 368 |
|
3892 | 369 |
! ! |
370 |
||
371 |
!FindFileApplication class methodsFor:'menu specs'! |
|
372 |
||
373 |
menu |
|
374 |
"This resource specification was automatically generated |
|
375 |
by the MenuEditor of ST/X." |
|
376 |
||
377 |
"Do not manually edit this!! If it is corrupted, |
|
378 |
the MenuEditor may not be able to read the specification." |
|
379 |
||
380 |
" |
|
381 |
MenuEditor new openOnClass:FindFileApplication andSelector:#menu |
|
382 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication menu)) startUp |
|
383 |
" |
|
384 |
||
385 |
<resource: #menu> |
|
386 |
||
387 |
^ |
|
5766 | 388 |
#(Menu |
389 |
( |
|
390 |
(MenuItem |
|
391 |
enabled: hasOneFileSelected |
|
392 |
label: 'Select in Browser' |
|
393 |
itemValue: selectInBrowser |
|
394 |
translateLabel: true |
|
395 |
isVisible: isEmbeddedApplication |
|
3892 | 396 |
) |
5766 | 397 |
(MenuItem |
6158 | 398 |
label: 'Autoselect in Browser' |
399 |
translateLabel: true |
|
400 |
indication: autoSelectInBrowserHolder |
|
401 |
) |
|
402 |
(MenuItem |
|
5766 | 403 |
enabled: hasOneFileSelected |
404 |
label: 'Open in New File Browser' |
|
405 |
itemValue: openInNewBrowser |
|
406 |
translateLabel: true |
|
407 |
) |
|
408 |
(MenuItem |
|
409 |
label: '-' |
|
410 |
) |
|
411 |
(MenuItem |
|
412 |
enabled: hasSelectionInResultList |
|
413 |
label: 'Copy Selected Filenames to Clipboard' |
|
414 |
itemValue: copySelectedFileNamesToClipboard |
|
415 |
translateLabel: true |
|
416 |
) |
|
417 |
(MenuItem |
|
418 |
label: '-' |
|
3892 | 419 |
) |
5766 | 420 |
(MenuItem |
5859 | 421 |
enabled: hasListEntries |
422 |
label: 'Delete all Files' |
|
423 |
itemValue: deleteAllFiles |
|
424 |
translateLabel: true |
|
425 |
) |
|
426 |
(MenuItem |
|
5766 | 427 |
enabled: hasSelection |
5767 | 428 |
label: 'Delete Selected Files' |
5766 | 429 |
itemValue: deleteSelectedFiles |
430 |
translateLabel: true |
|
431 |
) |
|
432 |
(MenuItem |
|
433 |
label: '-' |
|
3892 | 434 |
) |
5766 | 435 |
(MenuItem |
436 |
enabled: hasSelection |
|
5767 | 437 |
label: 'Remove Selected from Resultlist' |
5766 | 438 |
itemValue: removeSelectedFilesFromResultList |
439 |
translateLabel: true |
|
440 |
) |
|
441 |
(MenuItem |
|
442 |
enabled: hasListEntries |
|
443 |
label: 'Clear ResultList' |
|
444 |
itemValue: clearResultList |
|
445 |
translateLabel: true |
|
3892 | 446 |
) |
5859 | 447 |
(MenuItem |
448 |
label: '-' |
|
449 |
) |
|
450 |
(MenuItem |
|
451 |
label: 'Show Matched Files' |
|
452 |
itemValue: showMatchedFiles: |
|
453 |
translateLabel: true |
|
454 |
isVisible: notShowingMatchedFiles |
|
455 |
argument: true |
|
456 |
) |
|
457 |
(MenuItem |
|
458 |
label: 'Show Matching Files' |
|
459 |
itemValue: showMatchedFiles: |
|
460 |
translateLabel: true |
|
461 |
isVisible: showingMatchedFiles |
|
462 |
argument: false |
|
463 |
) |
|
3892 | 464 |
) |
465 |
nil |
|
466 |
nil |
|
467 |
) |
|
468 |
! |
|
469 |
||
470 |
searchMenu |
|
471 |
"This resource specification was automatically generated |
|
472 |
by the MenuEditor of ST/X." |
|
473 |
||
474 |
"Do not manually edit this!! If it is corrupted, |
|
475 |
the MenuEditor may not be able to read the specification." |
|
476 |
||
477 |
" |
|
478 |
MenuEditor new openOnClass:FindFileApplication andSelector:#searchMenu |
|
479 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication searchMenu)) startUp |
|
480 |
" |
|
481 |
||
482 |
<resource: #menu> |
|
483 |
||
484 |
^ |
|
485 |
#(#Menu |
|
486 |
#( |
|
487 |
#(#MenuItem |
|
488 |
#label: 'Search' |
|
489 |
#translateLabel: true |
|
490 |
#isButton: true |
|
491 |
#value: #doSearch |
|
6094 | 492 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #searchFileIcon) |
3892 | 493 |
) |
494 |
#(#MenuItem |
|
495 |
#label: 'Stop' |
|
496 |
#translateLabel: true |
|
497 |
#isButton: true |
|
498 |
#value: #stop |
|
499 |
#enabled: #enableStop |
|
500 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #stop22x22Icon) |
|
501 |
) |
|
502 |
#(#MenuItem |
|
503 |
#label: 'Close' |
|
504 |
#translateLabel: true |
|
505 |
#isButton: true |
|
506 |
#startGroup: #right |
|
507 |
#value: #doClose |
|
6093 | 508 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #removeTabIcon) |
3892 | 509 |
) |
510 |
) |
|
511 |
nil |
|
512 |
nil |
|
513 |
) |
|
514 |
! ! |
|
515 |
||
6107 | 516 |
!FindFileApplication class methodsFor:'startup & release'! |
517 |
||
518 |
releaseContentsInfoCache |
|
519 |
ContentsInfoCache := ContentsInfoCacheAccessLock := nil. |
|
520 |
! ! |
|
521 |
||
3892 | 522 |
!FindFileApplication class methodsFor:'tableColumns specs'! |
523 |
||
524 |
searchResultTable |
|
525 |
"This resource specification was automatically generated |
|
526 |
by the DataSetBuilder of ST/X." |
|
527 |
||
528 |
"Do not manually edit this!! If it is corrupted, |
|
529 |
the DataSetBuilder may not be able to read the specification." |
|
530 |
||
531 |
" |
|
532 |
DataSetBuilder new openOnClass:FindFileApplication andSelector:#searchResultTable |
|
533 |
" |
|
534 |
||
535 |
<resource: #tableColumns> |
|
536 |
||
537 |
^#( |
|
6583 | 538 |
(DataSetColumnSpec |
539 |
label: 'Filename' |
|
540 |
id: 'FileName' |
|
541 |
labelButtonType: Button |
|
542 |
model: fileName |
|
543 |
showRowSeparator: false |
|
544 |
showColSeparator: false |
|
3892 | 545 |
) |
546 |
) |
|
547 |
||
548 |
! ! |
|
549 |
||
550 |
!FindFileApplication methodsFor:'accessing'! |
|
551 |
||
552 |
accessLock |
|
553 |
"return the value of the instance variable 'accessLock' (automatically generated)" |
|
554 |
||
555 |
accessLock isNil ifTrue:[ |
|
556 |
accessLock := Semaphore forMutualExclusion name:'accessLock'. |
|
557 |
]. |
|
558 |
^ accessLock |
|
559 |
! |
|
560 |
||
561 |
stopSignal |
|
562 |
||
563 |
stopSignal isNil ifTrue:[ |
|
564 |
stopSignal := Signal new. |
|
565 |
]. |
|
566 |
^ stopSignal |
|
4101 | 567 |
! |
568 |
||
569 |
targetApplication:something |
|
570 |
"set the value of the instance variable 'targetApplication' (automatically generated)" |
|
571 |
||
572 |
targetApplication := something. |
|
3892 | 573 |
! ! |
574 |
||
575 |
!FindFileApplication methodsFor:'actions'! |
|
576 |
||
577 |
changeInformationTo:aString |
|
578 |
||
579 |
self changeInformationTo:aString toTab:false |
|
580 |
! |
|
581 |
||
582 |
changeInformationTo:aString toTab:aBoolean |
|
583 |
masterApplication isNil ifTrue:[ |
|
584 |
findFileView label:aString |
|
585 |
] ifFalse:[ |
|
586 |
aBoolean ifTrue:[ |
|
587 |
masterApplication tabStringChangeTo:aString for:self |
|
588 |
] |
|
589 |
]. |
|
590 |
! |
|
591 |
||
5850 | 592 |
clearCache |
6107 | 593 |
contentsInfoCache := nil |
5850 | 594 |
! |
595 |
||
5766 | 596 |
clearResultList |
597 |
self resultList removeAll. |
|
5859 | 598 |
self matchedFilesList removeAll. |
599 |
! |
|
600 |
||
601 |
clearShownList |
|
5864 | 602 |
self shownList removeAll. |
5766 | 603 |
! |
604 |
||
605 |
copySelectedFileNamesToClipboard |
|
3892 | 606 |
|sel list stream| |
607 |
||
608 |
sel := self selectionHolder value. |
|
5859 | 609 |
list := self shownList. |
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
610 |
(sel notEmptyOrNil) ifTrue:[ |
3892 | 611 |
stream := WriteStream on:''. |
612 |
sel do:[: key | |
|
613 |
stream nextPutAll:(list at:key). |
|
614 |
stream cr. |
|
615 |
]. |
|
6038
ed07ac0069b2
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
5961
diff
changeset
|
616 |
self window setClipboardText:stream contents. |
3892 | 617 |
stream close. |
618 |
]. |
|
619 |
! |
|
620 |
||
5766 | 621 |
deleteAllFiles |
622 |
|files| |
|
623 |
||
5864 | 624 |
files := self shownList copy. |
5766 | 625 |
self deleteFiles:files confirm:true. |
5859 | 626 |
self clearShownList. |
5766 | 627 |
! |
628 |
||
629 |
deleteFiles:colOfFiles confirm:confirm |
|
630 |
"delete current selected files/directories |
|
631 |
" |
|
632 |
|delete result| |
|
633 |
||
634 |
self windowGroup withWaitCursorDo:[ |
|
5961 | 635 |
delete := FileOperation deleteFiles:(colOfFiles asSet) confirm:confirm. |
5766 | 636 |
result := delete result. |
637 |
result notNil ifTrue:[ |
|
638 |
result ifFalse:[ |
|
639 |
self notify:delete errorString. |
|
640 |
] ifTrue:[ |
|
5769 | 641 |
"/ masterApplication notNil ifTrue:[ |
642 |
"/ masterApplication updateListAfterDelete:colOfFiles. |
|
643 |
"/ ] |
|
5766 | 644 |
] |
645 |
]. |
|
646 |
]. |
|
647 |
^ result. |
|
648 |
! |
|
649 |
||
650 |
deleteSelectedFiles |
|
5856 | 651 |
|sel files result| |
5766 | 652 |
|
653 |
sel := self selectionHolder value. |
|
6109 | 654 |
sel isEmptyOrNil ifTrue:[^ self]. |
655 |
||
5864 | 656 |
files := sel collect:[:idx | self shownList at:idx]. |
5766 | 657 |
self deleteFiles:files confirm:true. |
5856 | 658 |
result == true ifTrue:[ |
659 |
self removeSelectedFilesFromResultList. |
|
660 |
]. |
|
5766 | 661 |
! |
662 |
||
3892 | 663 |
doSearch |
664 |
||
5864 | 665 |
| namePattern namePatterns contentsPattern notContentsPattern dir fileToCompareAgainst thisSearchTask| |
3892 | 666 |
|
667 |
"/ self changeExtentToSeeSearchResult. |
|
668 |
||
669 |
dir := self searchDirectoryHolder value. |
|
670 |
dir isNil ifTrue:[ |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
671 |
Dialog warn:'Missing directory name'. |
3892 | 672 |
^ self. |
673 |
]. |
|
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
6183
diff
changeset
|
674 |
dir asFilename exists ifFalse:[ |
5786
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
675 |
Dialog warn:('No such directory: ''%1''' bindWith:dir asString allBold). |
3892 | 676 |
^ self. |
677 |
]. |
|
6442 | 678 |
|
679 |
LastSearchIgnoredCaseInFilename := ignoreCaseInName value. |
|
680 |
LastSearchIgnoredCaseInContents := ignoreCaseInContents value. |
|
681 |
||
3892 | 682 |
searchTask notNil ifTrue:[ |
683 |
(Dialog |
|
6355 | 684 |
confirm:(resources stringWithCRs:'There is already another find-file task running !!') |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
685 |
yesLabel:(resources at:'Stop other Task and Proceed') |
3892 | 686 |
noLabel:(resources at:'Cancel')) |
687 |
ifFalse:[^ self]. |
|
688 |
self stop. |
|
689 |
]. |
|
690 |
||
691 |
namePattern := self namePatternHolder value. |
|
692 |
namePattern size == 0 ifTrue:[ |
|
693 |
namePatterns := nil |
|
694 |
] ifFalse:[ |
|
695 |
ignoreCaseInName value ifTrue:[ |
|
696 |
namePattern := namePattern asLowercase |
|
697 |
]. |
|
5786
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
698 |
namePatterns := namePattern asCollectionOfSubstringsSeparatedBy:$;. |
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
699 |
namePatterns := namePatterns collect:[:each | each withoutSeparators]. |
3892 | 700 |
]. |
701 |
contentsPattern := self contentsPatternHolder value. |
|
702 |
contentsPattern size == 0 ifTrue:[ |
|
703 |
contentsPattern := nil |
|
704 |
] ifFalse:[ |
|
705 |
self ignoreCaseInContents value ifTrue:[ |
|
706 |
contentsPattern := contentsPattern asLowercase |
|
707 |
] |
|
708 |
]. |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
709 |
notContentsPattern := self notContentsPatternHolder value. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
710 |
notContentsPattern size == 0 ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
711 |
notContentsPattern := nil |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
712 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
713 |
self ignoreCaseInNotContents value ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
714 |
notContentsPattern := notContentsPattern asLowercase |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
715 |
] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
716 |
]. |
5787 | 717 |
searchForSameContents value ifTrue:[ |
718 |
fileToCompareAgainst := (self sameContentsAsHolder value ? '') withoutSeparators. |
|
719 |
fileToCompareAgainst isEmpty ifTrue:[ |
|
720 |
fileToCompareAgainst := nil. |
|
721 |
] ifFalse:[ |
|
722 |
fileToCompareAgainst includesMatchCharacters ifFalse:[ |
|
723 |
fileToCompareAgainst asFilename exists ifFalse:[ |
|
724 |
Dialog warn:('No such file: %1' bindWith:fileToCompareAgainst asString allBold). |
|
725 |
^ self. |
|
726 |
]. |
|
727 |
fileToCompareAgainst asFilename isReadable ifFalse:[ |
|
728 |
Dialog warn:('Cannot read: %1' bindWith:fileToCompareAgainst asString allBold). |
|
729 |
^ self. |
|
730 |
] |
|
5768 | 731 |
]. |
5726 | 732 |
]. |
5723 | 733 |
]. |
734 |
||
5864 | 735 |
searchTask := thisSearchTask := |
5776 | 736 |
[ |
737 |
|message t| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
738 |
|
5776 | 739 |
[ |
740 |
(self stopSignal) catch:[ |
|
741 |
self enableStop value:true. |
|
742 |
self resultList removeAll. |
|
5859 | 743 |
self matchedFilesList removeAll. |
5776 | 744 |
self changeInformationTo:'Find File ' , '- searching ' toTab:true. |
745 |
self notify:'searching...'. |
|
746 |
t := Time millisecondsToRun:[ |
|
5770 | 747 |
|
5776 | 748 |
self |
749 |
doFindFileNamed:namePatterns |
|
750 |
directories:(self searchDirectories value) |
|
751 |
ignoreCase:(self ignoreCaseInName value) |
|
752 |
containingString:contentsPattern |
|
753 |
ignoreCaseInContents:(self ignoreCaseInContents value) |
|
754 |
notContainingString:notContentsPattern |
|
755 |
ignoreCaseInNotContents:(self ignoreCaseInNotContents value) |
|
756 |
sameContentsAsFile:fileToCompareAgainst |
|
757 |
sameContentsAs:nil |
|
758 |
in:(self searchDirectoryHolder value). |
|
5770 | 759 |
|
5776 | 760 |
]. |
761 |
t > 100 ifTrue:[ |
|
762 |
t := ((t / 1000) asFixedPoint:2) printString , ' s' |
|
763 |
] ifFalse:[ |
|
764 |
t := t printString , ' ms' |
|
765 |
]. |
|
766 |
message := 'Found %1 file%2 in %3' bindWith:(resultList size) with:(resultList size == 1 ifTrue:'' ifFalse:'s') with:t. |
|
767 |
self enableStop value:false. |
|
768 |
self enableSearch value:true. |
|
769 |
self changeInformationTo:'Find File ' , '- done.' toTab:true. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
770 |
]. |
6154 | 771 |
] ensure:[ |
5864 | 772 |
thisSearchTask == searchTask ifTrue:[ |
773 |
searchTask := nil. |
|
774 |
self enableStop value:false. |
|
775 |
self notify:message. |
|
776 |
]. |
|
5776 | 777 |
] |
778 |
] newProcess. |
|
3892 | 779 |
|
5776 | 780 |
searchTask priorityRange:(Processor systemBackgroundPriority to:Processor userSchedulingPriority). |
3892 | 781 |
searchTask name:('FindFile[', self searchDirectoryHolder value asFilename baseName, ']'). |
782 |
searchTask resume. |
|
783 |
! |
|
784 |
||
785 |
openInNewBrowser |
|
786 |
|sel| |
|
787 |
||
788 |
sel := self selectionHolder value. |
|
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
789 |
(sel notEmptyOrNil) ifTrue:[ |
5859 | 790 |
FileBrowserV2 openOn:(self shownList at:sel first) asFilename |
3892 | 791 |
]. |
792 |
! |
|
793 |
||
5766 | 794 |
removeSelectedFilesFromResultList |
3892 | 795 |
|sel list| |
796 |
||
797 |
sel := self selectionHolder value. |
|
5864 | 798 |
list := self shownList. |
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
799 |
(sel notEmptyOrNil) ifTrue:[ |
3892 | 800 |
sel reverseDo:[: key | |
801 |
list removeAtIndex:key |
|
802 |
] |
|
803 |
]. |
|
804 |
! |
|
805 |
||
806 |
selectInBrowser |
|
807 |
|sel entry application| |
|
808 |
||
809 |
sel := self selectionHolder value. |
|
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
810 |
(sel notEmptyOrNil) ifTrue:[ |
5859 | 811 |
entry := self shownList at:sel first. |
5252 | 812 |
entry asFilename exists ifFalse:[ ^ self]. |
4101 | 813 |
application := targetApplication ? self masterApplication. |
4182 | 814 |
application notNil ifTrue:[ |
4101 | 815 |
application gotoFile:(entry asFilename). |
816 |
]. |
|
3892 | 817 |
]. |
818 |
! |
|
819 |
||
5859 | 820 |
showMatchedFiles:aBoolean |
821 |
aBoolean ifTrue:[ |
|
5864 | 822 |
self shownListHolder valueHolder:(self matchedFilesList) |
5859 | 823 |
] ifFalse:[ |
5864 | 824 |
self shownListHolder valueHolder:(self resultList) |
5859 | 825 |
]. |
826 |
! |
|
827 |
||
3892 | 828 |
stop |
829 |
||
830 |
searchTask notNil ifTrue:[ |
|
831 |
self accessLock critical:[ |
|
832 |
searchTask interruptWith:[stopSignal raiseRequest]. |
|
833 |
] |
|
834 |
]. |
|
835 |
self enableStop value:false. |
|
836 |
self enableSearch value:true. |
|
837 |
self changeInformationTo:'Find File ' , '- search stopped' toTab:true. |
|
838 |
! |
|
839 |
||
840 |
stopSearchTask |
|
841 |
|task| |
|
842 |
||
843 |
(task := searchTask) notNil ifTrue:[ |
|
844 |
searchTask := nil. |
|
845 |
||
846 |
Object errorSignal handle:[:ex| |
|
847 |
Dialog warn:ex description. |
|
848 |
]do:[ |
|
849 |
task isDead ifFalse:[ |
|
3937
80d958725879
terminateWithAllSUbprocesses -> xxxInGroup
Claus Gittinger <cg@exept.de>
parents:
3892
diff
changeset
|
850 |
task terminateWithAllSubprocessesInGroup. |
3892 | 851 |
task waitUntilTerminated. |
852 |
] |
|
853 |
] |
|
854 |
]. |
|
855 |
! ! |
|
856 |
||
857 |
!FindFileApplication methodsFor:'aspects'! |
|
858 |
||
5856 | 859 |
autoSelectInBrowser |
6330 | 860 |
^ self autoSelectInBrowserHolder value. |
6158 | 861 |
! |
862 |
||
863 |
autoSelectInBrowserHolder |
|
864 |
autoSelectInBrowserHolder isNil ifTrue:[ |
|
865 |
autoSelectInBrowserHolder := false asValue. |
|
866 |
]. |
|
867 |
^ autoSelectInBrowserHolder. |
|
5856 | 868 |
! |
869 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
870 |
canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
871 |
"grep command is much faster, but: |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
872 |
- not under MSDOS |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
873 |
" |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
874 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
875 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'egrep' ] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
876 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
877 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
878 |
canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
879 |
"locate command is much faster, but: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
880 |
- only if searching recursively, |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
881 |
- no case ignore |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
882 |
- no contents matching |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
883 |
" |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
884 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
885 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'locate' ] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
886 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
887 |
|
3892 | 888 |
contentsPatternHolder |
889 |
||
890 |
contentsPatternHolder isNil ifTrue:[ |
|
891 |
contentsPatternHolder := nil asValue. |
|
892 |
]. |
|
893 |
^ contentsPatternHolder. |
|
894 |
! |
|
895 |
||
6330 | 896 |
enableFileSizeFilter |
897 |
enableFileSizeFilter isNil ifTrue:[ |
|
898 |
enableFileSizeFilter := false asValue. |
|
899 |
]. |
|
900 |
^ enableFileSizeFilter. |
|
901 |
! |
|
902 |
||
903 |
enableFileSizeFilterAndNotSearchForSameContents |
|
904 |
^ BlockValue forLogical:self notSearchForSameContents and:self enableFileSizeFilter |
|
905 |
! |
|
906 |
||
3892 | 907 |
enableSearch |
908 |
||
909 |
enableSearch isNil ifTrue:[ |
|
910 |
enableSearch := true asValue. |
|
911 |
]. |
|
912 |
^ enableSearch. |
|
913 |
! |
|
914 |
||
915 |
enableStop |
|
916 |
||
917 |
enableStop isNil ifTrue:[ |
|
918 |
enableStop := true asValue. |
|
919 |
]. |
|
920 |
^ enableStop. |
|
921 |
! |
|
922 |
||
6330 | 923 |
fileSizeHolder |
924 |
fileSizeHolder isNil ifTrue:[ |
|
925 |
fileSizeHolder := 0 asValue. |
|
926 |
]. |
|
927 |
^ fileSizeHolder. |
|
928 |
! |
|
929 |
||
930 |
fileSizeOperatorHolder |
|
931 |
fileSizeOperatorHolder isNil ifTrue:[ |
|
932 |
fileSizeOperatorHolder := '>' asValue. |
|
933 |
]. |
|
934 |
^ fileSizeOperatorHolder. |
|
935 |
! |
|
936 |
||
937 |
fileSizeUnitHolder |
|
938 |
fileSizeUnitHolder isNil ifTrue:[ |
|
939 |
fileSizeUnitHolder := 'b' asValue. |
|
940 |
]. |
|
941 |
^ fileSizeUnitHolder. |
|
942 |
! |
|
943 |
||
3892 | 944 |
hasListEntries |
945 |
||
946 |
hasListEntries isNil ifTrue:[ |
|
947 |
hasListEntries := false asValue. |
|
948 |
]. |
|
949 |
^ hasListEntries. |
|
950 |
! |
|
951 |
||
952 |
ignoreCaseInContents |
|
953 |
ignoreCaseInContents isNil ifTrue:[ |
|
6442 | 954 |
ignoreCaseInContents := (LastSearchIgnoredCaseInContents |
955 |
? TextView lastSearchIgnoredCase |
|
956 |
? true) asValue. |
|
3892 | 957 |
]. |
958 |
^ ignoreCaseInContents. |
|
959 |
! |
|
960 |
||
961 |
ignoreCaseInName |
|
962 |
||
963 |
ignoreCaseInName isNil ifTrue:[ |
|
6442 | 964 |
ignoreCaseInName := (LastSearchIgnoredCaseInFilename |
965 |
? OperatingSystem caseSensitiveFilenames not) asValue. |
|
3892 | 966 |
]. |
967 |
^ ignoreCaseInName. |
|
968 |
! |
|
969 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
970 |
ignoreCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
971 |
ignoreCaseInNotContents isNil ifTrue:[ |
6442 | 972 |
ignoreCaseInNotContents := (LastSearchIgnoredCaseInContents |
973 |
? TextView lastSearchIgnoredCase |
|
974 |
? true) asValue. |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
975 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
976 |
^ ignoreCaseInNotContents. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
977 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
978 |
|
5859 | 979 |
matchedFilesList |
980 |
||
981 |
matchedFilesList isNil ifTrue:[ |
|
982 |
matchedFilesList := List new. |
|
983 |
matchedFilesList addDependent:self. |
|
984 |
]. |
|
985 |
^ matchedFilesList. |
|
986 |
! |
|
987 |
||
3892 | 988 |
namePatternHolder |
989 |
||
990 |
namePatternHolder isNil ifTrue:[ |
|
991 |
namePatternHolder := '*' asValue. |
|
992 |
]. |
|
993 |
^ namePatternHolder. |
|
994 |
! |
|
995 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
996 |
notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
997 |
notContentsPatternHolder isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
998 |
notContentsPatternHolder := nil asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
999 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1000 |
^ notContentsPatternHolder. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1001 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1002 |
|
3892 | 1003 |
notSearchForSameContents |
5743 | 1004 |
^ BlockValue forLogicalNot:self searchForSameContents |
3892 | 1005 |
! |
1006 |
||
5859 | 1007 |
notShowingMatchedFiles |
5865 | 1008 |
^ self shownList == self resultList |
5859 | 1009 |
! |
1010 |
||
5723 | 1011 |
rememberInCache |
1012 |
rememberInCache isNil ifTrue:[ |
|
5859 | 1013 |
rememberInCache := (LastRememberInCache ? false) asValue. |
5723 | 1014 |
]. |
1015 |
^ rememberInCache. |
|
1016 |
! |
|
1017 |
||
3892 | 1018 |
resultList |
1019 |
resultList isNil ifTrue:[ |
|
1020 |
resultList := List new. |
|
1021 |
resultList addDependent:self. |
|
1022 |
]. |
|
1023 |
^ resultList. |
|
1024 |
! |
|
1025 |
||
5723 | 1026 |
sameContentsAsHolder |
1027 |
|sel| |
|
1028 |
||
1029 |
sameContentsAsHolder isNil ifTrue:[ |
|
1030 |
sameContentsAsHolder := ValueHolder new. |
|
1031 |
masterApplication notNil ifTrue:[ |
|
1032 |
sel := masterApplication currentSelectedFiles. |
|
1033 |
sel size > 0 ifTrue:[ |
|
1034 |
sameContentsAsHolder value:(sel first asFilename pathName). |
|
1035 |
]. |
|
1036 |
]. |
|
1037 |
]. |
|
1038 |
^ sameContentsAsHolder. |
|
1039 |
! |
|
1040 |
||
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1041 |
searchDirectories |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1042 |
searchDirectories isNil ifTrue:[ |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1043 |
searchDirectories := false asValue. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1044 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1045 |
^ searchDirectories. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1046 |
! |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1047 |
|
3892 | 1048 |
searchDirectoryHolder |
1049 |
||
1050 |
searchDirectoryHolder isNil ifTrue:[ |
|
1051 |
searchDirectoryHolder := ValueHolder new. |
|
1052 |
]. |
|
1053 |
^ searchDirectoryHolder. |
|
1054 |
! |
|
1055 |
||
5743 | 1056 |
searchForSameContents |
1057 |
searchForSameContents isNil ifTrue:[ |
|
1058 |
searchForSameContents := false asValue. |
|
1059 |
]. |
|
1060 |
^ searchForSameContents. |
|
1061 |
! |
|
1062 |
||
5726 | 1063 |
searchOnlyInCache |
1064 |
searchOnlyInCache isNil ifTrue:[ |
|
1065 |
searchOnlyInCache := false asValue. |
|
1066 |
]. |
|
1067 |
^ searchOnlyInCache. |
|
1068 |
! |
|
1069 |
||
3892 | 1070 |
searchRecursively |
1071 |
||
1072 |
searchRecursively isNil ifTrue:[ |
|
1073 |
searchRecursively := true asValue. |
|
1074 |
]. |
|
1075 |
^ searchRecursively. |
|
1076 |
! |
|
1077 |
||
1078 |
searchResultTable |
|
1079 |
||
1080 |
searchResultTable isNil ifTrue:[ |
|
1081 |
searchResultTable := self class searchResultTable asValue. |
|
1082 |
]. |
|
1083 |
^ searchResultTable. |
|
1084 |
! |
|
1085 |
||
1086 |
selectionHolder |
|
1087 |
||
1088 |
selectionHolder isNil ifTrue:[ |
|
4101 | 1089 |
selectionHolder := ValueHolder new. |
1090 |
selectionHolder addDependent:self. |
|
3892 | 1091 |
]. |
1092 |
^ selectionHolder |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1093 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1094 |
|
5859 | 1095 |
showingMatchedFiles |
5865 | 1096 |
^ self shownList == self matchedFilesList |
5859 | 1097 |
! |
1098 |
||
1099 |
shownList |
|
5864 | 1100 |
^ self shownListHolder valueHolder. |
1101 |
! |
|
1102 |
||
1103 |
shownListHolder |
|
1104 |
shownListHolder isNil ifTrue:[ |
|
1105 |
shownListHolder := IndirectValue for:(self resultList). |
|
1106 |
shownListHolder addDependent:self. |
|
5859 | 1107 |
]. |
5864 | 1108 |
^ shownListHolder. |
5859 | 1109 |
! |
1110 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1111 |
useGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1112 |
useGrep isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1113 |
useGrep := false asValue. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1114 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1115 |
^ useGrep. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1116 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1117 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1118 |
useLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1119 |
useLocate isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1120 |
useLocate := false asValue. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1121 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1122 |
^ useLocate. |
3892 | 1123 |
! ! |
1124 |
||
1125 |
!FindFileApplication methodsFor:'change & update'! |
|
1126 |
||
1127 |
update:something with:aParameter from:changedObject |
|
5864 | 1128 |
changedObject == self shownListHolder ifTrue:[ |
5859 | 1129 |
self hasListEntries value:(changedObject valueHolder notEmpty). |
3892 | 1130 |
^ self |
1131 |
]. |
|
4101 | 1132 |
changedObject == self selectionHolder ifTrue:[ |
5856 | 1133 |
self autoSelectInBrowser ifTrue:[ |
1134 |
self selectInBrowser. |
|
1135 |
]. |
|
4101 | 1136 |
^ self |
1137 |
]. |
|
3892 | 1138 |
super update:something with:aParameter from:changedObject |
1139 |
! ! |
|
1140 |
||
1141 |
!FindFileApplication methodsFor:'event handling'! |
|
1142 |
||
4101 | 1143 |
fileDoubleClick:entries |
5677
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1144 |
|file fn app openedAppl contentsPattern| |
4101 | 1145 |
|
5859 | 1146 |
file := self shownList at:entries first. |
5677
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1147 |
fn := file asFilename. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1148 |
fn exists ifFalse:[ |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1149 |
Dialog warn:('File %1 does not (no longer ?) exist.' bindWith:file allBold). |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1150 |
^ self |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1151 |
]. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1152 |
|
4101 | 1153 |
app := targetApplication ? self masterApplication. |
5279 | 1154 |
file asFilename isDirectory ifTrue:[ |
1155 |
app gotoFile:(file asFilename). |
|
1156 |
^ self. |
|
1157 |
]. |
|
4101 | 1158 |
app notNil ifTrue:[ |
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1159 |
openedAppl := app openApplForFile:file. |
5279 | 1160 |
(openedAppl notNil and:[openedAppl isTextEditor]) ifTrue:[ |
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1161 |
contentsPattern := self contentsPatternHolder value. |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1162 |
(contentsPattern notNil and:[ contentsPattern notEmpty and:[contentsPattern ~= '*']]) ifTrue:[ |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1163 |
openedAppl searchForPattern:contentsPattern ignoreCase:(self ignoreCaseInContents value). |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1164 |
] |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1165 |
]. |
4101 | 1166 |
] ifFalse:[ |
1167 |
self openInNewBrowser. |
|
1168 |
] |
|
1169 |
! |
|
1170 |
||
3892 | 1171 |
processEvent:anEvent |
1172 |
"filter keyboard events. |
|
1173 |
Return true, if I have eaten the event" |
|
1174 |
||
1175 |
|focusView key rawKey| |
|
1176 |
||
1177 |
anEvent isKeyPressEvent ifTrue:[ |
|
1178 |
focusView := anEvent targetView. |
|
1179 |
key := anEvent key. |
|
1180 |
rawKey := anEvent rawKey. |
|
1181 |
||
1182 |
(focusView isSameOrComponentOf:self window) ifTrue:[ |
|
1183 |
(key == #Return) ifTrue:[ |
|
1184 |
(focusView name ~= 'selectionInListView') ifTrue:[ |
|
1185 |
self doSearch. |
|
1186 |
] ifFalse:[ |
|
1187 |
self hasOneFileSelected ifTrue:[ |
|
4101 | 1188 |
self fileDoubleClick:(self selectionHolder value) |
1189 |
"/ self isEmbeddedApplication ifTrue:[ |
|
1190 |
"/ self selectInBrowser. |
|
1191 |
"/ ] ifFalse:[ |
|
1192 |
"/ self openInNewBrowser. |
|
1193 |
"/ ] |
|
3892 | 1194 |
] |
1195 |
]. |
|
1196 |
^ true |
|
1197 |
]. |
|
1198 |
] |
|
1199 |
]. |
|
1200 |
^ false |
|
1201 |
! ! |
|
1202 |
||
1203 |
!FindFileApplication methodsFor:'private'! |
|
1204 |
||
1205 |
changeExtentToSeeSearchResult |
|
1206 |
||
1207 |
| extent window| |
|
1208 |
||
1209 |
expanded isNil ifTrue:[ |
|
1210 |
window := self builder window. |
|
1211 |
window ifNotNil:[ |
|
1212 |
window := window topView. |
|
1213 |
extent := window extent. |
|
1214 |
window extent:((extent x) @ (extent y + 300)). |
|
1215 |
expanded := true. |
|
1216 |
window containerChangedSize. |
|
1217 |
]. |
|
1218 |
]. |
|
1219 |
! ! |
|
1220 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1221 |
!FindFileApplication methodsFor:'private - searching'! |
3892 | 1222 |
|
5856 | 1223 |
cachedFileSizeOf:aFilenameString |
1224 |
|cache cacheLine fileSize| |
|
1225 |
||
1226 |
cache := self contentsInfoCache. |
|
1227 |
cache isNil ifTrue:[ |
|
5859 | 1228 |
fileSize := aFilenameString asFilename fileSize |
5856 | 1229 |
] ifFalse:[ |
5859 | 1230 |
ContentsInfoCacheAccessLock critical:[ |
1231 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1232 |
cacheLine isNil ifTrue:[ |
|
1233 |
cache at:aFilenameString put:(cacheLine := Array new:2). |
|
1234 |
] ifFalse:[ |
|
1235 |
fileSize := (cacheLine at:1). |
|
1236 |
]. |
|
5856 | 1237 |
|
5859 | 1238 |
fileSize isNil ifTrue:[ |
1239 |
fileSize := aFilenameString asFilename fileSize. |
|
1240 |
cacheLine at:1 put:fileSize. |
|
1241 |
]. |
|
1242 |
]. |
|
5856 | 1243 |
]. |
1244 |
^ fileSize |
|
1245 |
! |
|
1246 |
||
1247 |
cachedHashValueOfFile:aFilenameString |
|
1248 |
|cache cacheLine hashValue| |
|
1249 |
||
1250 |
cache := self contentsInfoCache. |
|
1251 |
cache isNil ifTrue:[ |
|
5859 | 1252 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename |
5856 | 1253 |
] ifFalse:[ |
5859 | 1254 |
ContentsInfoCacheAccessLock critical:[ |
1255 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1256 |
cacheLine isNil ifTrue:[ |
|
1257 |
cache at:aFilenameString put:(Array new:2). |
|
1258 |
] ifFalse:[ |
|
1259 |
hashValue := (cacheLine at:2). |
|
1260 |
]. |
|
5856 | 1261 |
|
5859 | 1262 |
hashValue isNil ifTrue:[ |
1263 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename. |
|
1264 |
cacheLine at:2 put:hashValue. |
|
1265 |
]. |
|
1266 |
]. |
|
5856 | 1267 |
]. |
1268 |
^ hashValue |
|
1269 |
! |
|
1270 |
||
1271 |
contentsInfoCache |
|
6107 | 1272 |
contentsInfoCache isNil ifTrue:[ |
1273 |
ContentsInfoCache isNil ifTrue:[ |
|
1274 |
ContentsInfoCache := Dictionary new. |
|
1275 |
ContentsInfoCacheAccessLock := Semaphore forMutualExclusion. |
|
1276 |
]. |
|
1277 |
contentsInfoCache := ContentsInfoCache |
|
5856 | 1278 |
]. |
6107 | 1279 |
^ contentsInfoCache |
5856 | 1280 |
! |
1281 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1282 |
doFindFileNamed:namePatterns directories:searchDirectories ignoreCase:ignCaseInName |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1283 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1284 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1285 |
sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory |
3892 | 1286 |
|
5859 | 1287 |
|dir nameMatches lines contentsToCompare resultList matchedFilesList inStream |
5601 | 1288 |
doesFileMatch contentsString notContentsString check checkNot |
5859 | 1289 |
grepCommand nameMatch fileSizesToSearchFor filesToSearchFor fileMD5sToSearchFor |
1290 |
setOfFilesToSearchFor remember cache fn| |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1291 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1292 |
contentsString := contentsStringArg. |
6183
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1293 |
contentsString notNil ifTrue:[ |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1294 |
ignCaseInContents ifTrue:[ contentsString := contentsString asLowercase ]. |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1295 |
]. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1296 |
notContentsString := notContentsStringArg. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1297 |
|
6183
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1298 |
notContentsString notNil ifTrue:[ |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1299 |
ignCaseInNotContents ifTrue:[ notContentsString := notContentsString asLowercase ]. |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1300 |
]. |
5723 | 1301 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5768 | 1302 |
fileSizesToSearchFor := OrderedCollection new. |
1303 |
filesToSearchFor := OrderedCollection new. |
|
1304 |
fileMD5sToSearchFor := OrderedCollection new. |
|
1305 |
||
1306 |
filenameToCompareContentsOrNil includesMatchCharacters ifTrue:[ |
|
1307 |
dir := filenameToCompareContentsOrNil asFilename. |
|
1308 |
[dir pathName includesMatchCharacters] whileTrue:[ |
|
1309 |
dir := dir directory |
|
1310 |
]. |
|
1311 |
dir recursiveDirectoryContentsDo:[:relName | |
|
1312 |
|path fn| |
|
1313 |
||
1314 |
fn := dir construct:relName. |
|
5770 | 1315 |
(filenameToCompareContentsOrNil match:fn name) ifTrue:[ |
5847 | 1316 |
fn isDirectory ifFalse:[ |
5856 | 1317 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5847 | 1318 |
filesToSearchFor add:(fn name). |
5856 | 1319 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5847 | 1320 |
] |
5768 | 1321 |
] |
1322 |
]. |
|
1323 |
] ifFalse:[ |
|
1324 |
fn := filenameToCompareContentsOrNil asFilename. |
|
5856 | 1325 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5768 | 1326 |
filesToSearchFor add:(fn pathName). |
5856 | 1327 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5768 | 1328 |
]. |
1329 |
||
5859 | 1330 |
remember := LastRememberInCache := self rememberInCache value. |
5723 | 1331 |
remember ifTrue:[ |
5856 | 1332 |
cache := self contentsInfoCache. |
5723 | 1333 |
]. |
5866 | 1334 |
setOfFilesToSearchFor := filesToSearchFor asSet. |
1335 |
]. |
|
5791 | 1336 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1337 |
dir := aDirectory asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1338 |
self changeInformationTo:'Find File ' , '- searching .' , ((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) toTab:false. |
3892 | 1339 |
|
5859 | 1340 |
resultList := self resultList. |
1341 |
matchedFilesList := self matchedFilesList. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1342 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1343 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1344 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1345 |
[:f | |
5859 | 1346 |
|contentsMatches mustValidateExistance |
1347 |
fileMD5 fileName fileSize cacheLine idxInList matchedFile| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1348 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1349 |
"/ contents compare ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1350 |
contentsMatches := false. |
5771 | 1351 |
fileName := f name. |
5859 | 1352 |
(setOfFilesToSearchFor includes:fileName) ifFalse:[ |
5850 | 1353 |
mustValidateExistance := false. |
5856 | 1354 |
|
5727 | 1355 |
cache notNil ifTrue:[ |
5859 | 1356 |
ContentsInfoCacheAccessLock critical:[ |
1357 |
cacheLine := cache at:fileName ifAbsent:nil. |
|
1358 |
cacheLine notNil ifTrue:[ |
|
1359 |
fileSize := cacheLine at:1. |
|
1360 |
fileMD5 := cacheLine at:2. |
|
1361 |
mustValidateExistance := true. |
|
1362 |
]. |
|
5727 | 1363 |
]. |
5723 | 1364 |
]. |
5850 | 1365 |
|
5723 | 1366 |
fileSize isNil ifTrue:[ |
1367 |
fileSize := f fileSize. |
|
1368 |
]. |
|
1369 |
remember ifTrue:[ |
|
5859 | 1370 |
ContentsInfoCacheAccessLock critical:[ |
1371 |
cacheLine := cache at:fileName ifAbsentPut:[Array new:2]. |
|
1372 |
cacheLine at:1 put:fileSize. |
|
1373 |
] |
|
5723 | 1374 |
]. |
5768 | 1375 |
(idxInList := fileSizesToSearchFor indexOf:fileSize) ~~ 0 ifTrue:[ |
5723 | 1376 |
fileMD5 isNil ifTrue:[ |
5850 | 1377 |
OpenError handle:[:ex | |
1378 |
ObjectMemory garbageCollect. |
|
1379 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1380 |
] do:[ |
|
1381 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1382 |
]. |
|
5723 | 1383 |
remember ifTrue:[ |
1384 |
cacheLine at:2 put:fileMD5 |
|
1385 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1386 |
]. |
5768 | 1387 |
contentsMatches := (fileMD5 = (fileMD5sToSearchFor at:idxInList)). |
5850 | 1388 |
contentsMatches ifTrue:[ |
1389 |
mustValidateExistance ifTrue:[ |
|
1390 |
fileName asFilename exists ifFalse:[ |
|
5859 | 1391 |
ContentsInfoCacheAccessLock critical:[ |
1392 |
cache removeKey:fileName. |
|
1393 |
]. |
|
5850 | 1394 |
contentsMatches := false. |
1395 |
]. |
|
5859 | 1396 |
]. |
1397 |
contentsMatches ifTrue:[ |
|
1398 |
matchedFile := filesToSearchFor at:idxInList. |
|
1399 |
matchedFilesList add:matchedFile. |
|
1400 |
]. |
|
5850 | 1401 |
]. |
5723 | 1402 |
"/ contentsToCompare isNil ifTrue:[ |
1403 |
"/ filenameToCompareContentsOrNil fileSize < (512*1024) ifTrue:[ |
|
1404 |
"/ contentsToCompare := filenameToCompareContentsOrNil binaryContentsOfEntireFile |
|
1405 |
"/ ] |
|
1406 |
"/ ]. |
|
1407 |
"/ contentsToCompare isNil ifTrue:[ |
|
1408 |
"/ "/ too large - compare block-wise ... |
|
1409 |
"/ contentsMatches := (filenameToCompareContentsOrNil sameContentsAs:f). |
|
1410 |
"/ ] ifFalse:[ |
|
1411 |
"/ contentsMatches := contentsToCompare = (f binaryContentsOfEntireFile). |
|
1412 |
"/ ] |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1413 |
]. |
5773 | 1414 |
] ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1415 |
f isSymbolicLink ifTrue:[ |
5859 | 1416 |
resultList add: (f name , ' is a symbolic link to ' , f pathName). |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1417 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1418 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1419 |
contentsMatches |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1420 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1421 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1422 |
(contentsString isNil and:[notContentsString isNil]) ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1423 |
doesFileMatch := [:f | true]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1424 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1425 |
(self canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1426 |
and:[self useGrep value]) ifTrue:[ |
5601 | 1427 |
(ignCaseInContents not and:[ignCaseInNotContents not]) ifTrue:[ |
1428 |
contentsString notNil ifTrue:[ |
|
1429 |
notContentsString notNil ifTrue:[ |
|
1430 |
grepCommand := '(grep "',contentsString,'" %1) && (grep -v "',notContentsString,'" %1)'. |
|
1431 |
] ifFalse:[ |
|
1432 |
grepCommand := 'grep "' , contentsString , '" %1'. |
|
1433 |
]. |
|
1434 |
] ifFalse:[ |
|
1435 |
grepCommand := 'grep -v "' , notContentsString , '" %1'. |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1436 |
]. |
5601 | 1437 |
doesFileMatch := [:f | |cmd ret| |
1438 |
cmd := grepCommand bindWith:f pathName. |
|
1439 |
ret := OperatingSystem executeCommand:cmd. |
|
1440 |
ret |
|
1441 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1442 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1443 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1444 |
|
5601 | 1445 |
doesFileMatch isNil ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1446 |
contentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1447 |
ignCaseInContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1448 |
check := [:l | l asLowercase includesString:contentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1449 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1450 |
check := [:l | l includesString:contentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1451 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1452 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1453 |
notContentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1454 |
ignCaseInNotContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1455 |
checkNot := [:l | l asLowercase includesString:notContentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1456 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1457 |
checkNot := [:l | l includesString:notContentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1458 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1459 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1460 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1461 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1462 |
[:f | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1463 |
|contentsMatches| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1464 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1465 |
"/ string search ... |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1466 |
contentsMatches := true. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1467 |
(f exists and:[f isReadable]) ifFalse:[ |
5859 | 1468 |
resultList add: (('*** ' , f pathName , ' skipped - unreadable or bad symbolic link ***') asText colorizeAllWith:(Color red darkened)). |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1469 |
] ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1470 |
f fileSize > (4024*1024) ifTrue:[ |
5859 | 1471 |
resultList add: (('*** ' , f pathName , ' skipped - too large ***') asText colorizeAllWith:(Color red darkened)). |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1472 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1473 |
Stream lineTooLongErrorSignal handle:[:ex | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1474 |
|cont| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1475 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1476 |
"/ this typically happens, when a binary file is read linewise ... |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1477 |
cont := f readStream binary contentsOfEntireFile asString. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1478 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1479 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1480 |
contentsMatches := check value:cont |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1481 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1482 |
contentsMatches := (check value:cont) and:[(checkNot value:cont) not]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1483 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1484 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1485 |
contentsMatches := (checkNot value:cont) not. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1486 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1487 |
] do:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1488 |
lines := f contents ? #(). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1489 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1490 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1491 |
contentsMatches := (lines contains:check). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1492 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1493 |
contentsMatches := (lines contains:check) and:[(lines contains:checkNot) not] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1494 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1495 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1496 |
contentsMatches := (lines contains:checkNot) not. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1497 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1498 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1499 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1500 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1501 |
contentsMatches |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1502 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1503 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1504 |
]. |
6330 | 1505 |
self enableFileSizeFilter value ifTrue:[ |
1506 |
|fileSizeToCompare sizeMatch op oldDoesFileMatch| |
|
1507 |
||
1508 |
fileSizeToCompare := self fileSizeHolder value. |
|
1509 |
op := self fileSizeOperatorHolder value. |
|
1510 |
op = '~' ifTrue:[ |
|
1511 |
sizeMatch := [:f | |sz| sz := f fileSize. sz between:fileSizeToCompare*0.9 and:fileSizeToCompare*1.1]. |
|
1512 |
] ifFalse:[ |
|
1513 |
op := op asSymbol. |
|
1514 |
sizeMatch := [:f | f fileSize perform:op with:fileSizeToCompare]. |
|
1515 |
]. |
|
1516 |
oldDoesFileMatch := doesFileMatch. |
|
1517 |
doesFileMatch := [:f | (sizeMatch value:f) and:[ oldDoesFileMatch value:f ]] |
|
1518 |
]. |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1519 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1520 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1521 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1522 |
(self canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1523 |
and:[self useLocate value |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1524 |
and:[searchDirectories not]]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1525 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1526 |
[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1527 |
|cmd line f| |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1528 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1529 |
cmd := 'locate '. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1530 |
ignCaseInName ifTrue:[ |
5408 | 1531 |
cmd := cmd , '--ignore-case ' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1532 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1533 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1534 |
cmd := cmd , ((namePatterns collect:[:nm | dir asFilename asAbsoluteFilename constructString:nm]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1535 |
asStringCollection asStringWith:Character space). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1536 |
inStream := PipeStream readingFrom:cmd inDirectory:dir. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1537 |
[inStream atEnd] whileFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1538 |
line := inStream nextLine. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1539 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1540 |
f := line asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1541 |
(doesFileMatch value:f) ifTrue:[ |
5859 | 1542 |
resultList add:line. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1543 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1544 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1545 |
] ensure:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1546 |
inStream notNil ifTrue:[inStream close]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1547 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1548 |
^ self. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1549 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1550 |
|
3892 | 1551 |
bytesToCompareContentsOrNil notNil ifTrue:[ |
1552 |
contentsToCompare := bytesToCompareContentsOrNil |
|
1553 |
]. |
|
1554 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1555 |
namePatterns isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1556 |
nameMatch := [:fn | true] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1557 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1558 |
ignCaseInName ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1559 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1560 |
nameMatches := namePatterns contains:[:aPattern | aPattern match:(fn asLowercase)] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1561 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1562 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1563 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1564 |
nameMatches := namePatterns contains:[:aPattern | aPattern match:fn] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1565 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1566 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1567 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1568 |
|
5726 | 1569 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5727 | 1570 |
self searchOnlyInCache value ifTrue:[ |
5726 | 1571 |
cache notEmptyOrNil ifTrue:[ |
1572 |
cache keysAndValuesDo:[:fn :info | |
|
5768 | 1573 |
|filesSize filesMD5 idxInList| |
5727 | 1574 |
|
5726 | 1575 |
filesSize := info at:1. |
1576 |
filesSize isNil ifTrue:[ |
|
1577 |
filesSize := fn asFilename fileSize. |
|
1578 |
info at:1 put:filesSize. |
|
1579 |
]. |
|
5768 | 1580 |
(idxInList := fileSizesToSearchFor indexOf:filesSize) ~~ 0 ifTrue:[ |
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
6183
diff
changeset
|
1581 |
(setOfFilesToSearchFor includes:fn) ifFalse:[ |
5729 | 1582 |
fn asFilename exists ifFalse:[ |
1583 |
info at:1 put:nil. |
|
1584 |
info at:2 put:nil. |
|
1585 |
] ifTrue:[ |
|
1586 |
filesMD5 := info at:2. |
|
1587 |
filesMD5 isNil ifTrue:[ |
|
1588 |
filesMD5 := MD5Stream hashValueOfFile:fn asFilename. |
|
1589 |
info at:2 put:filesMD5. |
|
1590 |
]. |
|
5768 | 1591 |
filesMD5 = (fileMD5sToSearchFor at:idxInList) ifTrue:[ |
5859 | 1592 |
resultList add:fn. |
5728 | 1593 |
] |
5727 | 1594 |
] |
5726 | 1595 |
] |
1596 |
] |
|
1597 |
]. |
|
1598 |
]. |
|
1599 |
^ self. |
|
1600 |
]. |
|
1601 |
]. |
|
1602 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1603 |
self |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1604 |
doFindFileNamed:namePatterns |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1605 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1606 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1607 |
contentsMatch:doesFileMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1608 |
in:dir. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1609 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1610 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1611 |
doFindFileNamed:namePatterns directories:searchDirectories nameMatch:nameMatch contentsMatch:doesFileMatch in:aDirectory |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1612 |
|dir subDirs list directoryContents| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1613 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1614 |
dir := aDirectory asFilename. |
5844 | 1615 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1616 |
self changeInformationTo:'Find File ' , '- searching .' , ((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) toTab:false. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1617 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1618 |
list := self resultList. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1619 |
|
3892 | 1620 |
subDirs := OrderedCollection new. |
1621 |
||
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1622 |
[ |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1623 |
directoryContents := dir directoryContents. |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1624 |
] on:FileStream openErrorSignal do:[:ex| |
5811
c397040c27b4
openErrorSignal arg: always a string
Claus Gittinger <cg@exept.de>
parents:
5791
diff
changeset
|
1625 |
list add:((ex pathName , ' -> ' , ex description) asText colorizeAllWith:Color red darkened). |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1626 |
"/ self warn:('Cannot access %1\(%2)' |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1627 |
"/ bindWith:ex parameter printString |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1628 |
"/ with:ex description) withCRs. |
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1629 |
^ self |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1630 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1631 |
|
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1632 |
directoryContents sort do:[:fn | |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1633 |
|f isDirectory| |
3892 | 1634 |
|
1635 |
f := dir construct:fn. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1636 |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1637 |
isDirectory := f isDirectory. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1638 |
isDirectory ifTrue:[ |
3892 | 1639 |
f isSymbolicLink ifFalse:[ |
1640 |
subDirs add:f |
|
1641 |
] |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1642 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1643 |
(searchDirectories or:[isDirectory not]) ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1644 |
(nameMatch value:fn) ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1645 |
(isDirectory or:[ doesFileMatch value:f ]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1646 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1647 |
list add:(f asString). |
3892 | 1648 |
] |
1649 |
] |
|
1650 |
] |
|
1651 |
]. |
|
1652 |
||
1653 |
self searchRecursively value ifTrue:[ |
|
1654 |
subDirs do:[:dir | |
|
1655 |
self |
|
1656 |
doFindFileNamed:namePatterns |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1657 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1658 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1659 |
contentsMatch:doesFileMatch |
3892 | 1660 |
in:dir |
1661 |
]. |
|
1662 |
] |
|
1663 |
! ! |
|
1664 |
||
1665 |
!FindFileApplication methodsFor:'queries'! |
|
1666 |
||
1667 |
getTabStringEnd |
|
1668 |
||
1669 |
" get the tab string from the application list on the class side " |
|
1670 |
||
1671 |
^ self fileName directory asString |
|
1672 |
! |
|
1673 |
||
1674 |
hasOneFileSelected |
|
1675 |
| sel | |
|
1676 |
sel := self selectionHolder value. |
|
1677 |
^ (sel notNil and:[sel notEmpty and:[sel size = 1]]) |
|
1678 |
! |
|
1679 |
||
1680 |
hasSelectionInResultList |
|
1681 |
| sel | |
|
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
1682 |
|
3892 | 1683 |
sel := self selectionHolder value. |
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
1684 |
^ sel notEmptyOrNil |
3892 | 1685 |
! ! |
1686 |
||
1687 |
!FindFileApplication methodsFor:'startup & release'! |
|
1688 |
||
5010 | 1689 |
item:anItem |
3892 | 1690 |
|
4797 | 1691 |
|file newPattern| |
3892 | 1692 |
|
5010 | 1693 |
super item:anItem. |
4797 | 1694 |
|
3892 | 1695 |
file := self fileName. |
1696 |
self searchDirectoryHolder value:(self getDirWithoutFileName:file). |
|
4797 | 1697 |
|
3892 | 1698 |
file isDirectory ifTrue:[ |
4797 | 1699 |
newPattern := '*'. |
3892 | 1700 |
] ifFalse:[ |
5010 | 1701 |
newPattern := '*.', anItem suffix. |
3892 | 1702 |
]. |
4797 | 1703 |
self namePatternHolder value:newPattern. |
3892 | 1704 |
self enableStop value:false. |
1705 |
self enableSearch value:true. |
|
1706 |
^ true. |
|
1707 |
! |
|
1708 |
||
1709 |
postOpenWith:aBuilder |
|
1710 |
||
1711 |
self masterApplication isNil ifTrue:[ |
|
1712 |
self masterApplication:nil. |
|
1713 |
]. |
|
1714 |
findFileView := aBuilder window. |
|
1715 |
self windowGroup addPreEventHook:self. |
|
1716 |
^ super postOpenWith:aBuilder. |
|
1717 |
! |
|
1718 |
||
1719 |
release |
|
1720 |
self stopSearchTask. |
|
6107 | 1721 |
contentsInfoCache := nil. |
3892 | 1722 |
^ super release |
1723 |
! ! |
|
1724 |
||
1725 |
!FindFileApplication class methodsFor:'documentation'! |
|
1726 |
||
1727 |
version |
|
6583 | 1728 |
^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.75 2006-02-20 10:17:30 cg Exp $' |
3892 | 1729 |
! ! |