author | Claus Gittinger <cg@exept.de> |
Mon, 20 Jan 2020 21:02:47 +0100 | |
changeset 19422 | c6ca1c3e0fd7 |
parent 19417 | 2f5d4b7bc507 |
child 19503 | c4e9982b4847 |
permissions | -rw-r--r-- |
19417 | 1 |
"{ Encoding: utf8 }" |
2 |
||
5140 | 3 |
" |
4 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
3892 | 14 |
"{ Package: 'stx:libtool' }" |
15 |
||
15092 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
11096 | 18 |
AbstractFileFinderApplicationComponent subclass:#FindFileApplication |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
19 |
instanceVariableNames:'searchDirectories searchDirectoryHolder notSearchForSameContents |
10441 | 20 |
namePatternHolder excludedNamePatternHolder ignoreCaseInName |
21 |
ignoreCaseInExcludedName contentsPatternHolder |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
22 |
ignoreCaseInContents notContentsPatternHolder |
11096 | 23 |
ignoreCaseInNotContents sameContentsAsHolder useLocate useGrep |
5859 | 24 |
rememberInCache searchOnlyInCache searchForSameContents |
11096 | 25 |
contentsInfoCache contentsInfoCacheAccessLock |
6330 | 26 |
fileSizeOperatorHolder fileSizeHolder enableFileSizeFilter |
11473 | 27 |
fileSizeUnitHolder modificationTimeOperatorHolder |
13920 | 28 |
modificationTimeHolder enableModificationTimeFilter |
16810 | 29 |
showUnreadableFilesAndDirectoriesHolder |
17751 | 30 |
modificationTimeOperatorIndexHolder searchForBinaryContentsHolder' |
6442 | 31 |
classVariableNames:'ContentsInfoCache ContentsInfoCacheAccessLock LastRememberInCache |
8330 | 32 |
LastSearchIgnoredCaseInContents LastSearchIgnoredCaseInFilename |
13920 | 33 |
SearchStringHistory LastSearchIgnoredCaseInExcludedFilename |
17751 | 34 |
LastShowUnreadableFilesAndDirectories LastSearchForBinaryContents' |
3892 | 35 |
poolDictionaries:'' |
36 |
category:'Interface-Tools-File' |
|
37 |
! |
|
38 |
||
5140 | 39 |
!FindFileApplication class methodsFor:'documentation'! |
40 |
||
41 |
copyright |
|
42 |
" |
|
43 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
44 |
All Rights Reserved |
|
45 |
||
46 |
This software is furnished under a license and may be used |
|
47 |
only in accordance with the terms of that license and with the |
|
48 |
inclusion of the above copyright notice. This software may not |
|
49 |
be provided or otherwise made available to, or used by, any |
|
50 |
other person. No title to or ownership of the software is |
|
51 |
hereby transferred. |
|
52 |
" |
|
53 |
! ! |
|
3892 | 54 |
|
55 |
!FindFileApplication class methodsFor:'instance creation'! |
|
56 |
||
57 |
open |
|
5723 | 58 |
^ self openInDirectory:(Filename currentDirectory) |
3892 | 59 |
|
5723 | 60 |
" |
61 |
self open |
|
62 |
" |
|
63 |
! |
|
64 |
||
65 |
openInDirectory:aFilename |
|
66 |
^ self openOnFileName:(aFilename asFilename asAbsoluteFilename) |
|
67 |
||
68 |
" |
|
69 |
self openInDirectory:'/etc' |
|
70 |
" |
|
3892 | 71 |
! |
72 |
||
73 |
openOnFileName:aFileName |
|
5723 | 74 |
^ self openOnFileName:aFileName for:nil |
75 |
! |
|
76 |
||
77 |
openOnFileName:aFileName for:aTargetApplicationOrNil |
|
3892 | 78 |
|
79 |
| instance builder| |
|
80 |
||
81 |
builder := super open. |
|
82 |
instance := builder application. |
|
3983 | 83 |
instance item:(DirectoryContentsBrowser itemClass fileName:aFileName). |
5723 | 84 |
aTargetApplicationOrNil notNil ifTrue:[ |
85 |
instance targetApplication:aTargetApplicationOrNil. |
|
86 |
]. |
|
3892 | 87 |
^ builder |
88 |
! ! |
|
89 |
||
90 |
!FindFileApplication class methodsFor:'defaults'! |
|
91 |
||
92 |
tabStringFor:aApplicationType |
|
7688 | 93 |
"the formatString shown in a tab (language translated)" |
3892 | 94 |
|
7688 | 95 |
^ 'Find in %1' |
96 |
||
97 |
"Modified: / 01-03-2007 / 21:47:54 / cg" |
|
3892 | 98 |
! ! |
99 |
||
9408 | 100 |
!FindFileApplication class methodsFor:'help specs'! |
101 |
||
17894 | 102 |
helpSpec |
9408 | 103 |
"This resource specification was automatically generated |
104 |
by the UIHelpTool of ST/X." |
|
105 |
||
106 |
"Do not manually edit this!! If it is corrupted, |
|
107 |
the UIHelpTool may not be able to read the specification." |
|
108 |
||
109 |
" |
|
110 |
UIHelpTool openOnClass:FindFileApplication |
|
111 |
" |
|
112 |
||
113 |
<resource: #help> |
|
114 |
||
17894 | 115 |
^ super helpSpec addPairsFrom:#( |
9408 | 116 |
|
117 |
#contentsPattern |
|
17751 | 118 |
'Search for files containing this. Can be matchPatterns, separated by ";".\If search for binary contents is checked, this should be a sequence of hex bytes (i.e. xx xx xx...)' |
9408 | 119 |
|
120 |
#namePattern |
|
17709 | 121 |
'Filename(s) to search for. Can be matchPatterns, separated by ";".\(eg. "*.c ; *.h" searches for C and header files. So does "*.[ch]")' |
9408 | 122 |
|
11122 | 123 |
#excludedNamePattern |
124 |
'Filename(s) to skip. Can be matchPatterns, separated by ";"' |
|
125 |
||
9408 | 126 |
#notContentsPattern |
17751 | 127 |
'Search for files NOT containing this. Can be matchPatterns, separated by ";".\If search for binary contents is checked, this should be a sequence of hex bytes (i.e. xx xx xx...)' |
9408 | 128 |
|
129 |
#searchDirectory |
|
130 |
'Folder, where the search starts' |
|
131 |
||
17751 | 132 |
#searchForBinaryContents |
133 |
'Included/Not included patterns are given as a sequence of hex bytes instead of character sequences (eg. xx xx xx...)' |
|
134 |
||
9408 | 135 |
#searchRecursive |
136 |
'Recursively search in sub-folders' |
|
137 |
||
138 |
#ignoreCase |
|
139 |
'Ignore upper/lowercase differences (be case-insensitive)' |
|
140 |
||
141 |
#sameContents |
|
142 |
'Search for files with same contents as the other file' |
|
143 |
||
144 |
#fileSize |
|
11097 | 145 |
'Search for files with a specific size constraint ("~" means: +/- 10%)' |
9408 | 146 |
|
11473 | 147 |
#modificationTime |
148 |
'Search for files which are newer or older' |
|
9408 | 149 |
) |
11097 | 150 |
|
17751 | 151 |
"Modified: / 12-11-2017 / 17:53:35 / cg" |
9408 | 152 |
! ! |
153 |
||
8330 | 154 |
!FindFileApplication class methodsFor:'history'! |
155 |
||
156 |
addToSearchStringHistory:aString |
|
157 |
self searchStringHistory |
|
158 |
remove:aString ifAbsent:[]; |
|
159 |
addFirst:aString. |
|
160 |
self searchStringHistory size > 25 ifTrue:[ |
|
161 |
self searchStringHistory removeLast |
|
162 |
]. |
|
163 |
! |
|
164 |
||
165 |
searchStringHistory |
|
166 |
SearchStringHistory isNil ifTrue:[ |
|
167 |
SearchStringHistory := OrderedCollection new |
|
168 |
]. |
|
169 |
^ SearchStringHistory |
|
170 |
! ! |
|
171 |
||
3892 | 172 |
!FindFileApplication class methodsFor:'interface specs'! |
173 |
||
174 |
windowSpec |
|
175 |
"This resource specification was automatically generated |
|
176 |
by the UIPainter of ST/X." |
|
177 |
||
178 |
"Do not manually edit this!! If it is corrupted, |
|
179 |
the UIPainter may not be able to read the specification." |
|
180 |
||
181 |
" |
|
182 |
UIPainter new openOnClass:FindFileApplication andSelector:#windowSpec |
|
183 |
FindFileApplication new openInterface:#windowSpec |
|
184 |
FindFileApplication open |
|
185 |
" |
|
186 |
||
187 |
<resource: #canvas> |
|
188 |
||
189 |
^ |
|
13920 | 190 |
#(FullSpec |
191 |
name: windowSpec |
|
17751 | 192 |
uuid: '79f42116-c7c7-11e7-82f7-c42c033b4871' |
13920 | 193 |
window: |
194 |
(WindowSpec |
|
195 |
label: 'File Search' |
|
196 |
name: 'File Search' |
|
17751 | 197 |
uuid: '79f4341c-c7c7-11e7-82f7-c42c033b4871' |
13920 | 198 |
min: (Point 377 131) |
199 |
bounds: (Rectangle 0 0 759 420) |
|
200 |
) |
|
201 |
component: |
|
202 |
(SpecCollection |
|
203 |
collection: ( |
|
204 |
(MenuPanelSpec |
|
205 |
name: 'ToolBar1' |
|
206 |
layout: (LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
17751 | 207 |
uuid: '79f4376e-c7c7-11e7-82f7-c42c033b4871' |
13920 | 208 |
level: 0 |
209 |
menu: searchMenu |
|
210 |
textDefault: true |
|
211 |
) |
|
212 |
(ProgressIndicatorSpec |
|
213 |
name: 'ProgressIndicator1' |
|
214 |
layout: (LayoutFrame 125 0 11 0 231 0 21 0) |
|
17751 | 215 |
uuid: '79f43a48-c7c7-11e7-82f7-c42c033b4871' |
13920 | 216 |
visibilityChannel: enableStop |
16810 | 217 |
backgroundColor: (Color 0.0 67.0 67.0) |
13920 | 218 |
showPercentage: false |
219 |
isActivityIndicator: true |
|
220 |
) |
|
221 |
(ViewSpec |
|
222 |
name: 'Box1' |
|
223 |
layout: (LayoutFrame 0 0.0 32 0 0 1.0 231 0) |
|
17751 | 224 |
uuid: '79f43caa-c7c7-11e7-82f7-c42c033b4871' |
13920 | 225 |
component: |
226 |
(SpecCollection |
|
227 |
collection: ( |
|
228 |
(LabelSpec |
|
229 |
label: 'Directory:' |
|
230 |
name: 'DirectoryLabel' |
|
16810 | 231 |
layout: (LayoutFrame 2 0 7 0 180 0 24 0) |
13920 | 232 |
activeHelpKey: searchDirectory |
17751 | 233 |
uuid: '79f43e3a-c7c7-11e7-82f7-c42c033b4871' |
13920 | 234 |
translateLabel: true |
235 |
adjust: right |
|
236 |
) |
|
237 |
(FilenameInputFieldSpec |
|
238 |
name: 'DirectoryEntryField' |
|
16810 | 239 |
layout: (LayoutFrame 180 0 4 0 -350 1 24 0) |
13920 | 240 |
activeHelpKey: searchDirectory |
17751 | 241 |
uuid: '79f44056-c7c7-11e7-82f7-c42c033b4871' |
13920 | 242 |
model: searchDirectoryHolder |
243 |
immediateAccept: true |
|
244 |
acceptOnPointerLeave: false |
|
245 |
) |
|
246 |
(LabelSpec |
|
247 |
label: 'Search Files Named:' |
|
248 |
name: 'FileNameLabel' |
|
16810 | 249 |
layout: (LayoutFrame 2 0 31 0 180 0 48 0) |
13920 | 250 |
activeHelpKey: namePattern |
17751 | 251 |
uuid: '79f4433a-c7c7-11e7-82f7-c42c033b4871' |
13920 | 252 |
translateLabel: true |
253 |
adjust: right |
|
254 |
) |
|
255 |
(InputFieldSpec |
|
256 |
name: 'FileNameEntryField' |
|
16810 | 257 |
layout: (LayoutFrame 180 0 28 0 -350 1 48 0) |
13920 | 258 |
activeHelpKey: namePattern |
17751 | 259 |
uuid: '79f444b6-c7c7-11e7-82f7-c42c033b4871' |
13920 | 260 |
tabable: true |
261 |
model: namePatternHolder |
|
262 |
immediateAccept: true |
|
263 |
acceptOnLeave: false |
|
264 |
acceptOnPointerLeave: false |
|
265 |
) |
|
266 |
(LabelSpec |
|
267 |
label: 'But not Named:' |
|
268 |
name: 'Label1' |
|
16810 | 269 |
layout: (LayoutFrame 2 0 55 0 180 0 72 0) |
13920 | 270 |
activeHelpKey: excludedNamePattern |
17751 | 271 |
uuid: '79f44704-c7c7-11e7-82f7-c42c033b4871' |
13920 | 272 |
translateLabel: true |
273 |
adjust: right |
|
274 |
) |
|
275 |
(InputFieldSpec |
|
276 |
name: 'EntryField1' |
|
16810 | 277 |
layout: (LayoutFrame 180 0 52 0 -350 1 72 0) |
13920 | 278 |
activeHelpKey: excludedNamePattern |
17751 | 279 |
uuid: '79f44880-c7c7-11e7-82f7-c42c033b4871' |
13920 | 280 |
tabable: true |
281 |
model: excludedNamePatternHolder |
|
282 |
immediateAccept: true |
|
283 |
acceptOnLeave: false |
|
284 |
acceptOnPointerLeave: false |
|
285 |
) |
|
286 |
(LabelSpec |
|
287 |
label: 'Containing:' |
|
288 |
name: 'ContentsLabel' |
|
16810 | 289 |
layout: (LayoutFrame 2 0 79 0 180 0 96 0) |
13920 | 290 |
activeHelpKey: contentsPattern |
17751 | 291 |
uuid: '79f44a88-c7c7-11e7-82f7-c42c033b4871' |
13920 | 292 |
translateLabel: true |
293 |
adjust: right |
|
294 |
) |
|
295 |
(ComboBoxSpec |
|
296 |
name: 'ComboBox1' |
|
16810 | 297 |
layout: (LayoutFrame 180 0 76 0 -350 1 96 0) |
13920 | 298 |
activeHelpKey: contentsPattern |
17751 | 299 |
uuid: '79f44bfa-c7c7-11e7-82f7-c42c033b4871' |
13920 | 300 |
enableChannel: notSearchForSameContents |
301 |
tabable: true |
|
302 |
model: contentsPatternHolder |
|
303 |
immediateAccept: true |
|
304 |
acceptOnPointerLeave: false |
|
305 |
comboList: searchStringHistory |
|
16810 | 306 |
useIndex: false |
13920 | 307 |
) |
308 |
(LabelSpec |
|
309 |
label: 'Not Containing:' |
|
310 |
name: 'NotContentsLabel' |
|
16810 | 311 |
layout: (LayoutFrame 2 0 103 0 180 0 120 0) |
13920 | 312 |
activeHelpKey: notContentsPattern |
17751 | 313 |
uuid: '79f44ea2-c7c7-11e7-82f7-c42c033b4871' |
13920 | 314 |
translateLabel: true |
315 |
adjust: right |
|
316 |
) |
|
317 |
(InputFieldSpec |
|
318 |
name: 'NotContentsEntryField' |
|
16810 | 319 |
layout: (LayoutFrame 180 0 100 0 -350 1 120 0) |
13920 | 320 |
activeHelpKey: notContentsPattern |
17751 | 321 |
uuid: '79f4500a-c7c7-11e7-82f7-c42c033b4871' |
13920 | 322 |
enableChannel: notSearchForSameContents |
323 |
tabable: true |
|
324 |
model: notContentsPatternHolder |
|
325 |
immediateAccept: true |
|
326 |
acceptOnPointerLeave: false |
|
327 |
) |
|
328 |
(LabelSpec |
|
329 |
label: 'Same Contents As:' |
|
330 |
name: 'SameContentsAsLabel' |
|
16810 | 331 |
layout: (LayoutFrame 2 0 127 0 180 0 144 0) |
13920 | 332 |
activeHelpKey: sameContents |
17751 | 333 |
uuid: '79f45208-c7c7-11e7-82f7-c42c033b4871' |
13920 | 334 |
translateLabel: true |
335 |
adjust: right |
|
336 |
) |
|
337 |
(InputFieldSpec |
|
338 |
name: 'SameContentsAsEntryField' |
|
16810 | 339 |
layout: (LayoutFrame 180 0 124 0 -367 1 144 0) |
13920 | 340 |
activeHelpKey: sameContents |
17751 | 341 |
uuid: '79f45370-c7c7-11e7-82f7-c42c033b4871' |
13920 | 342 |
enableChannel: searchForSameContents |
343 |
tabable: true |
|
344 |
model: sameContentsAsHolder |
|
345 |
immediateAccept: true |
|
346 |
acceptOnPointerLeave: false |
|
347 |
) |
|
348 |
(CheckToggleSpec |
|
349 |
name: 'EnableSameContentsCheckToggle' |
|
16810 | 350 |
layout: (LayoutOrigin -366 1 128 0) |
13920 | 351 |
activeHelpKey: sameContents |
17751 | 352 |
uuid: '79f45582-c7c7-11e7-82f7-c42c033b4871' |
16810 | 353 |
translateLabel: true |
13920 | 354 |
model: searchForSameContents |
355 |
isTriggerOnDown: true |
|
356 |
showLamp: false |
|
357 |
lampColor: (Color 100.0 100.0 0.0) |
|
358 |
) |
|
359 |
(LabelSpec |
|
360 |
label: 'File Size:' |
|
361 |
name: 'FileSizeLabel' |
|
16810 | 362 |
layout: (LayoutFrame 2 0 151 0 180 0 168 0) |
13920 | 363 |
activeHelpKey: fileSize |
17751 | 364 |
uuid: '79f458c0-c7c7-11e7-82f7-c42c033b4871' |
13920 | 365 |
translateLabel: true |
366 |
adjust: right |
|
367 |
) |
|
368 |
(PopUpListSpec |
|
369 |
label: 'PopUp List' |
|
370 |
name: 'FileSizeOperatorPopUpList' |
|
16810 | 371 |
layout: (LayoutFrame 180 0 148 0 260 0 168 0) |
13920 | 372 |
activeHelpKey: fileSize |
17751 | 373 |
uuid: '79f45a64-c7c7-11e7-82f7-c42c033b4871' |
16810 | 374 |
translateLabel: true |
13920 | 375 |
tabable: true |
376 |
model: fileSizeOperatorHolder |
|
377 |
enableChannel: enableFileSizeFilterAndNotSearchForSameContents |
|
378 |
menu: |
|
379 |
(Array |
|
380 |
' >' ' < ' |
|
381 |
' !!= ' ' = ' |
|
382 |
' ~ ' |
|
383 |
) |
|
3892 | 384 |
) |
13920 | 385 |
(InputFieldSpec |
386 |
name: 'FileSizeEntryField' |
|
16810 | 387 |
layout: (LayoutFrame 260 0 148 0 -367 1 168 0) |
13920 | 388 |
activeHelpKey: fileSize |
17751 | 389 |
uuid: '79f45cda-c7c7-11e7-82f7-c42c033b4871' |
13920 | 390 |
enableChannel: enableFileSizeFilterAndNotSearchForSameContents |
391 |
tabable: true |
|
392 |
model: fileSizeHolder |
|
393 |
type: fileSize |
|
394 |
immediateAccept: false |
|
395 |
acceptOnLeave: true |
|
396 |
acceptOnLostFocus: true |
|
397 |
acceptOnPointerLeave: true |
|
398 |
) |
|
399 |
(CheckToggleSpec |
|
400 |
name: 'EnableSizeCheckToggle' |
|
16810 | 401 |
layout: (LayoutOrigin -366 1 151 0) |
13920 | 402 |
activeHelpKey: fileSize |
17751 | 403 |
uuid: '79f45f0a-c7c7-11e7-82f7-c42c033b4871' |
16810 | 404 |
translateLabel: true |
13920 | 405 |
model: enableFileSizeFilter |
406 |
enableChannel: notSearchForSameContents |
|
407 |
isTriggerOnDown: true |
|
408 |
showLamp: false |
|
409 |
lampColor: (Color 100.0 100.0 0.0) |
|
410 |
) |
|
411 |
(LabelSpec |
|
412 |
label: 'Modified:' |
|
413 |
name: 'Label2' |
|
16810 | 414 |
layout: (LayoutFrame 2 0 175 0 180 0 192 0) |
13920 | 415 |
activeHelpKey: modificationTime |
17751 | 416 |
uuid: '79f46130-c7c7-11e7-82f7-c42c033b4871' |
13920 | 417 |
translateLabel: true |
418 |
adjust: right |
|
419 |
) |
|
420 |
(PopUpListSpec |
|
421 |
label: 'PopUp List' |
|
422 |
name: 'PopUpList1' |
|
16810 | 423 |
layout: (LayoutFrame 180 0 172 0 260 0 192 0) |
13920 | 424 |
activeHelpKey: modificationTime |
17751 | 425 |
uuid: '79f462b6-c7c7-11e7-82f7-c42c033b4871' |
16810 | 426 |
translateLabel: true |
13920 | 427 |
tabable: true |
16810 | 428 |
model: modificationTimeOperatorIndexHolder |
13920 | 429 |
enableChannel: enableModificationTimeFilter |
16810 | 430 |
menu: modificationTimeOperatorLabelList |
431 |
useIndex: true |
|
13920 | 432 |
) |
433 |
(InputFieldSpec |
|
16810 | 434 |
name: 'ModifiedEntryField' |
435 |
layout: (LayoutFrame 260 0 172 0 -367 1 192 0) |
|
13920 | 436 |
activeHelpKey: modificationTime |
17751 | 437 |
uuid: '79f46478-c7c7-11e7-82f7-c42c033b4871' |
13920 | 438 |
enableChannel: enableModificationTimeFilter |
439 |
tabable: true |
|
440 |
model: modificationTimeHolder |
|
441 |
type: timestamp |
|
442 |
immediateAccept: false |
|
443 |
acceptOnLeave: true |
|
444 |
acceptOnLostFocus: true |
|
445 |
acceptOnPointerLeave: true |
|
446 |
) |
|
447 |
(CheckToggleSpec |
|
448 |
name: 'CheckToggle1' |
|
16810 | 449 |
layout: (LayoutOrigin -366 1 175 0) |
13920 | 450 |
activeHelpKey: modificationTime |
17751 | 451 |
uuid: '79f4668a-c7c7-11e7-82f7-c42c033b4871' |
16810 | 452 |
translateLabel: true |
13920 | 453 |
model: enableModificationTimeFilter |
454 |
isTriggerOnDown: true |
|
455 |
showLamp: false |
|
456 |
lampColor: (Color 100.0 100.0 0.0) |
|
457 |
) |
|
458 |
(CheckBoxSpec |
|
459 |
label: 'Use ''locate'' Cmd' |
|
460 |
name: 'UseLocateCheckBox' |
|
16810 | 461 |
layout: (LayoutFrame -350 1 5 0 -167 1 28 0) |
13920 | 462 |
activeHelpKey: useLocate |
17751 | 463 |
uuid: '79f4689c-c7c7-11e7-82f7-c42c033b4871' |
13920 | 464 |
visibilityChannel: canUseLocate |
465 |
tabable: true |
|
466 |
model: useLocate |
|
467 |
translateLabel: true |
|
468 |
) |
|
469 |
(CheckBoxSpec |
|
470 |
label: 'Recursive' |
|
471 |
name: 'RecursiveSearchCheckBox' |
|
16810 | 472 |
layout: (LayoutFrame -200 1 5 0 -4 1 28 0) |
13920 | 473 |
activeHelpKey: recursiveSearch |
17751 | 474 |
uuid: '79f46aa4-c7c7-11e7-82f7-c42c033b4871' |
13920 | 475 |
tabable: true |
476 |
model: searchRecursively |
|
477 |
translateLabel: true |
|
478 |
) |
|
479 |
(CheckBoxSpec |
|
480 |
label: 'Directories' |
|
481 |
name: 'SearchDirectoriesCheckBox' |
|
16810 | 482 |
layout: (LayoutFrame -350 1 29 0 -167 1 52 0) |
17751 | 483 |
uuid: '79f46c16-c7c7-11e7-82f7-c42c033b4871' |
13920 | 484 |
enableChannel: notSearchForSameContents |
485 |
tabable: true |
|
486 |
model: searchDirectories |
|
487 |
translateLabel: true |
|
488 |
) |
|
489 |
(CheckBoxSpec |
|
490 |
label: 'Ignore Case' |
|
491 |
name: 'IgnoreCaseInNameCheckBox' |
|
16810 | 492 |
layout: (LayoutFrame -200 1 29 0 -4 1 52 0) |
13920 | 493 |
activeHelpKey: ignoreCase |
17751 | 494 |
uuid: '79f46d7e-c7c7-11e7-82f7-c42c033b4871' |
13920 | 495 |
tabable: true |
496 |
model: ignoreCaseInName |
|
497 |
translateLabel: true |
|
498 |
) |
|
499 |
(CheckBoxSpec |
|
500 |
label: 'Ignore Case' |
|
501 |
name: 'CheckBox1' |
|
16810 | 502 |
layout: (LayoutFrame -200 1 53 0 -4 1 76 0) |
13920 | 503 |
activeHelpKey: ignoreCase |
17751 | 504 |
uuid: '79f46edc-c7c7-11e7-82f7-c42c033b4871' |
13920 | 505 |
tabable: true |
506 |
model: ignoreCaseInExcludedName |
|
507 |
translateLabel: true |
|
508 |
) |
|
509 |
(CheckBoxSpec |
|
510 |
label: 'Use ''grep'' Cmd' |
|
511 |
name: 'UseGrepCheckBox' |
|
16810 | 512 |
layout: (LayoutFrame -350 1 77 0 -167 1 100 0) |
17751 | 513 |
uuid: '79f4703a-c7c7-11e7-82f7-c42c033b4871' |
13920 | 514 |
visibilityChannel: canUseGrep |
515 |
enableChannel: notSearchForSameContents |
|
516 |
tabable: true |
|
517 |
model: useGrep |
|
518 |
translateLabel: true |
|
519 |
) |
|
520 |
(CheckBoxSpec |
|
521 |
label: 'Ignore Case' |
|
522 |
name: 'IgnoreCaseInContentsCheckBox' |
|
16810 | 523 |
layout: (LayoutFrame -200 1 77 0 -4 1 100 0) |
13920 | 524 |
activeHelpKey: ignoreCase |
17751 | 525 |
uuid: '79f47198-c7c7-11e7-82f7-c42c033b4871' |
13920 | 526 |
enableChannel: notSearchForSameContents |
527 |
tabable: true |
|
528 |
model: ignoreCaseInContents |
|
529 |
translateLabel: true |
|
530 |
) |
|
531 |
(CheckBoxSpec |
|
532 |
label: 'Ignore Case' |
|
533 |
name: 'IgnoreCaseInNotContentsCheckBox' |
|
16810 | 534 |
layout: (LayoutFrame -200 1 101 0 -4 1 124 0) |
13920 | 535 |
activeHelpKey: ignoreCase |
17751 | 536 |
uuid: '79f472f6-c7c7-11e7-82f7-c42c033b4871' |
13920 | 537 |
enableChannel: notSearchForSameContents |
538 |
tabable: true |
|
539 |
model: ignoreCaseInNotContents |
|
540 |
translateLabel: true |
|
541 |
) |
|
542 |
(CheckBoxSpec |
|
543 |
label: 'Cache Info' |
|
544 |
name: 'RememberInCacheCheckBox' |
|
16810 | 545 |
layout: (LayoutFrame -350 1 125 0 -167 1 148 0) |
17751 | 546 |
uuid: '79f47454-c7c7-11e7-82f7-c42c033b4871' |
13920 | 547 |
visibilityChannel: canUseGrep |
548 |
enableChannel: searchForSameContents |
|
549 |
tabable: true |
|
550 |
model: rememberInCache |
|
551 |
translateLabel: true |
|
17751 | 552 |
activeHelpKey: rememberInCache |
13920 | 553 |
) |
554 |
(ActionButtonSpec |
|
555 |
label: 'Clear Cache' |
|
556 |
name: 'ClearCacheButton' |
|
16965 | 557 |
layout: (LayoutFrame -169 1 125 0 -21 1 147 0) |
17751 | 558 |
uuid: '79f475b2-c7c7-11e7-82f7-c42c033b4871' |
13920 | 559 |
translateLabel: true |
560 |
model: clearCache |
|
17751 | 561 |
activeHelpKey: clearCache |
13920 | 562 |
) |
563 |
(CheckBoxSpec |
|
564 |
label: 'Show Unreadable Files and Folders' |
|
565 |
name: 'CheckBox2' |
|
16810 | 566 |
layout: (LayoutFrame -350 1 149 0 0 1 172 0) |
17751 | 567 |
uuid: '79f477b0-c7c7-11e7-82f7-c42c033b4871' |
13920 | 568 |
tabable: true |
569 |
model: showUnreadableFilesAndDirectoriesHolder |
|
570 |
translateLabel: true |
|
17751 | 571 |
activeHelpKey: showUnreadableFilesAndDirectories |
572 |
) |
|
573 |
(CheckBoxSpec |
|
574 |
label: 'Search for Binary Contents' |
|
575 |
name: 'CheckBox3' |
|
576 |
layout: (LayoutFrame -350 1 173 0 0 1 196 0) |
|
577 |
uuid: '79f47918-c7c7-11e7-82f7-c42c033b4871' |
|
578 |
tabable: true |
|
579 |
model: searchForBinaryContentsHolder |
|
580 |
translateLabel: true |
|
581 |
activeHelpKey: searchForBinaryContents |
|
13920 | 582 |
) |
583 |
) |
|
584 |
||
585 |
) |
|
3892 | 586 |
) |
13920 | 587 |
(SequenceViewSpec |
588 |
name: 'List1' |
|
589 |
layout: (LayoutFrame 0 0.0 238 0 0 1.0 0 1) |
|
17751 | 590 |
uuid: '79f47abc-c7c7-11e7-82f7-c42c033b4871' |
13920 | 591 |
model: selectionHolder |
592 |
menu: menu |
|
593 |
hasHorizontalScrollBar: true |
|
594 |
hasVerticalScrollBar: true |
|
595 |
isMultiSelect: true |
|
18987 | 596 |
doubleClickSelector: fileListDoubleClick: |
13920 | 597 |
valueChangeSelector: fileSelected: |
598 |
useIndex: true |
|
599 |
sequenceList: shownListHolder |
|
600 |
properties: |
|
601 |
(PropertyListDictionary |
|
16810 | 602 |
dropObjectSelector: getDropObjects: |
13920 | 603 |
displayObjectSelector: getDisplayObjects: |
604 |
startDragSelector: doStartDrag:in: |
|
605 |
dragArgument: findFileList |
|
606 |
) |
|
607 |
) |
|
608 |
) |
|
609 |
||
610 |
) |
|
611 |
) |
|
16810 | 612 |
|
17751 | 613 |
"Modified: / 12-11-2017 / 17:37:30 / cg" |
3892 | 614 |
! ! |
615 |
||
616 |
!FindFileApplication class methodsFor:'menu specs'! |
|
617 |
||
618 |
menu |
|
619 |
"This resource specification was automatically generated |
|
620 |
by the MenuEditor of ST/X." |
|
621 |
||
622 |
"Do not manually edit this!! If it is corrupted, |
|
623 |
the MenuEditor may not be able to read the specification." |
|
624 |
||
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
625 |
|
3892 | 626 |
" |
627 |
MenuEditor new openOnClass:FindFileApplication andSelector:#menu |
|
628 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication menu)) startUp |
|
629 |
" |
|
630 |
||
631 |
<resource: #menu> |
|
632 |
||
633 |
^ |
|
5766 | 634 |
#(Menu |
635 |
( |
|
636 |
(MenuItem |
|
637 |
enabled: hasOneFileSelected |
|
7323 | 638 |
label: 'Open in New File Browser' |
639 |
itemValue: openInNewBrowser |
|
640 |
) |
|
641 |
(MenuItem |
|
642 |
enabled: hasOneFileSelected |
|
5766 | 643 |
label: 'Select in Browser' |
644 |
itemValue: selectInBrowser |
|
645 |
isVisible: isEmbeddedApplication |
|
3892 | 646 |
) |
5766 | 647 |
(MenuItem |
6158 | 648 |
label: 'Autoselect in Browser' |
649 |
indication: autoSelectInBrowserHolder |
|
650 |
) |
|
651 |
(MenuItem |
|
5766 | 652 |
label: '-' |
653 |
) |
|
654 |
(MenuItem |
|
8613 | 655 |
enabled: hasOneFileSelected |
656 |
label: 'FileIn' |
|
657 |
itemValue: fileInInBrowser |
|
658 |
) |
|
659 |
(MenuItem |
|
660 |
label: '-' |
|
661 |
) |
|
662 |
(MenuItem |
|
5766 | 663 |
enabled: hasSelectionInResultList |
664 |
label: 'Copy Selected Filenames to Clipboard' |
|
665 |
itemValue: copySelectedFileNamesToClipboard |
|
666 |
) |
|
667 |
(MenuItem |
|
668 |
label: '-' |
|
3892 | 669 |
) |
5766 | 670 |
(MenuItem |
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
671 |
enabled: hasSelection |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
672 |
label: 'Delete Selected File(s)...' |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
673 |
itemValue: deleteSelectedFiles |
12494 | 674 |
) |
675 |
(MenuItem |
|
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
676 |
enabled: hasListEntries |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
677 |
label: 'Delete all Files...' |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
678 |
itemValue: deleteAllFiles |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
679 |
isVisible: false |
5766 | 680 |
) |
681 |
(MenuItem |
|
682 |
label: '-' |
|
16826 | 683 |
) |
684 |
(MenuItem |
|
685 |
enabled: hasSelection |
|
686 |
label: 'Touch Selected File(s)...' |
|
687 |
itemValue: touchSelectedFiles |
|
688 |
) |
|
689 |
(MenuItem |
|
690 |
enabled: hasListEntries |
|
691 |
label: 'Touch all Files...' |
|
692 |
itemValue: touchAllFiles |
|
693 |
isVisible: false |
|
694 |
) |
|
695 |
(MenuItem |
|
696 |
label: '-' |
|
12778 | 697 |
isVisible: cvsMenusAreShown |
698 |
) |
|
699 |
(MenuItem |
|
700 |
enabled: hasSelection |
|
701 |
label: 'Commit Selected File(s) to CVS...' |
|
702 |
itemValue: commitSelectedFilesToCVS |
|
703 |
isVisible: cvsMenusAreShown |
|
704 |
) |
|
705 |
(MenuItem |
|
706 |
enabled: hasSelection |
|
707 |
label: 'Delete Selected File(s) and CVS Container(s)...' |
|
708 |
itemValue: deleteSelectedFilesAndCVSContainers |
|
709 |
isVisible: cvsMenusAreShown |
|
710 |
) |
|
711 |
(MenuItem |
|
712 |
label: '-' |
|
3892 | 713 |
) |
5766 | 714 |
(MenuItem |
715 |
enabled: hasSelection |
|
5767 | 716 |
label: 'Remove Selected from Resultlist' |
5766 | 717 |
itemValue: removeSelectedFilesFromResultList |
718 |
) |
|
719 |
(MenuItem |
|
720 |
enabled: hasListEntries |
|
7691 | 721 |
label: 'Clear Resultlist' |
5766 | 722 |
itemValue: clearResultList |
3892 | 723 |
) |
5859 | 724 |
(MenuItem |
725 |
label: '-' |
|
726 |
) |
|
727 |
(MenuItem |
|
7691 | 728 |
label: 'Show Matched Files (After SameContents-Search)' |
5859 | 729 |
itemValue: showMatchedFiles: |
730 |
isVisible: notShowingMatchedFiles |
|
731 |
argument: true |
|
732 |
) |
|
733 |
(MenuItem |
|
7691 | 734 |
label: 'Show Matching Files (After SameContents-Search)' |
5859 | 735 |
itemValue: showMatchedFiles: |
736 |
isVisible: showingMatchedFiles |
|
737 |
argument: false |
|
738 |
) |
|
15214 | 739 |
(MenuItem |
740 |
enabled: hasTwoFilesSelected |
|
741 |
label: 'Compare with Each Other' |
|
742 |
itemValue: doCompareTwoFiles |
|
743 |
argument: false |
|
744 |
) |
|
3892 | 745 |
) |
746 |
nil |
|
747 |
nil |
|
748 |
) |
|
749 |
! |
|
750 |
||
751 |
searchMenu |
|
752 |
"This resource specification was automatically generated |
|
753 |
by the MenuEditor of ST/X." |
|
754 |
||
755 |
"Do not manually edit this!! If it is corrupted, |
|
756 |
the MenuEditor may not be able to read the specification." |
|
757 |
||
11101 | 758 |
|
3892 | 759 |
" |
760 |
MenuEditor new openOnClass:FindFileApplication andSelector:#searchMenu |
|
761 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication searchMenu)) startUp |
|
762 |
" |
|
763 |
||
764 |
<resource: #menu> |
|
765 |
||
766 |
^ |
|
7574 | 767 |
#(Menu |
768 |
( |
|
769 |
(MenuItem |
|
770 |
label: 'Search' |
|
771 |
itemValue: doSearch |
|
772 |
translateLabel: true |
|
773 |
isButton: true |
|
774 |
labelImage: (ResourceRetriever ToolbarIconLibrary searchFileIcon) |
|
3892 | 775 |
) |
7574 | 776 |
(MenuItem |
777 |
enabled: enableStop |
|
778 |
label: 'Stop' |
|
779 |
itemValue: stop |
|
780 |
translateLabel: true |
|
781 |
isButton: true |
|
782 |
isVisible: enableStop |
|
19417 | 783 |
labelImage: (ResourceRetriever ToolbarIconLibrary stop22x22Icon) |
3892 | 784 |
) |
7574 | 785 |
(MenuItem |
786 |
label: 'Close' |
|
787 |
itemValue: doClose |
|
788 |
translateLabel: true |
|
789 |
isButton: true |
|
790 |
startGroup: right |
|
11101 | 791 |
isVisible: false |
7574 | 792 |
labelImage: (ResourceRetriever ToolbarIconLibrary removeTabIcon) |
3892 | 793 |
) |
794 |
) |
|
795 |
nil |
|
796 |
nil |
|
797 |
) |
|
798 |
! ! |
|
799 |
||
6107 | 800 |
!FindFileApplication class methodsFor:'startup & release'! |
801 |
||
802 |
releaseContentsInfoCache |
|
803 |
ContentsInfoCache := ContentsInfoCacheAccessLock := nil. |
|
804 |
! ! |
|
805 |
||
3892 | 806 |
!FindFileApplication class methodsFor:'tableColumns specs'! |
807 |
||
808 |
searchResultTable |
|
809 |
"This resource specification was automatically generated |
|
810 |
by the DataSetBuilder of ST/X." |
|
811 |
||
812 |
"Do not manually edit this!! If it is corrupted, |
|
813 |
the DataSetBuilder may not be able to read the specification." |
|
814 |
||
815 |
" |
|
816 |
DataSetBuilder new openOnClass:FindFileApplication andSelector:#searchResultTable |
|
817 |
" |
|
818 |
||
819 |
<resource: #tableColumns> |
|
820 |
||
821 |
^#( |
|
6583 | 822 |
(DataSetColumnSpec |
823 |
label: 'Filename' |
|
824 |
id: 'FileName' |
|
825 |
labelButtonType: Button |
|
826 |
model: fileName |
|
827 |
showRowSeparator: false |
|
828 |
showColSeparator: false |
|
3892 | 829 |
) |
830 |
) |
|
831 |
||
832 |
! ! |
|
833 |
||
834 |
!FindFileApplication methodsFor:'actions'! |
|
835 |
||
5850 | 836 |
clearCache |
6107 | 837 |
contentsInfoCache := nil |
5850 | 838 |
! |
839 |
||
5766 | 840 |
clearResultList |
841 |
self resultList removeAll. |
|
5859 | 842 |
self matchedFilesList removeAll. |
843 |
! |
|
844 |
||
5766 | 845 |
deleteAllFiles |
846 |
|files| |
|
847 |
||
5864 | 848 |
files := self shownList copy. |
5766 | 849 |
self deleteFiles:files confirm:true. |
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
850 |
self removeFilesFromResultList:files |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
851 |
|
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
852 |
"Modified: / 29-03-2012 / 10:06:09 / cg" |
5766 | 853 |
! |
854 |
||
855 |
deleteFiles:colOfFiles confirm:confirm |
|
856 |
"delete current selected files/directories |
|
857 |
" |
|
858 |
|delete result| |
|
859 |
||
6832
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
860 |
"/ self windowGroup withWaitCursorDo:[ |
5961 | 861 |
delete := FileOperation deleteFiles:(colOfFiles asSet) confirm:confirm. |
5766 | 862 |
result := delete result. |
863 |
result notNil ifTrue:[ |
|
864 |
result ifFalse:[ |
|
865 |
self notify:delete errorString. |
|
866 |
] ifTrue:[ |
|
5769 | 867 |
"/ masterApplication notNil ifTrue:[ |
868 |
"/ masterApplication updateListAfterDelete:colOfFiles. |
|
869 |
"/ ] |
|
5766 | 870 |
] |
871 |
]. |
|
6832
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
872 |
"/ ]. |
5766 | 873 |
^ result. |
6832
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
874 |
|
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
875 |
"Modified: / 25-07-2006 / 09:11:09 / cg" |
5766 | 876 |
! |
877 |
||
878 |
deleteSelectedFiles |
|
5856 | 879 |
|sel files result| |
5766 | 880 |
|
881 |
sel := self selectionHolder value. |
|
6109 | 882 |
sel isEmptyOrNil ifTrue:[^ self]. |
883 |
||
5864 | 884 |
files := sel collect:[:idx | self shownList at:idx]. |
5766 | 885 |
self deleteFiles:files confirm:true. |
5856 | 886 |
result == true ifTrue:[ |
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
887 |
self removeFilesFromResultList:files |
5856 | 888 |
]. |
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
889 |
|
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
890 |
"Modified: / 29-03-2012 / 10:05:39 / cg" |
5766 | 891 |
! |
892 |
||
15214 | 893 |
doCompareTwoFiles |
894 |
|sel entry1 entry2| |
|
895 |
||
896 |
sel := self selectionHolder value. |
|
897 |
sel size == 2 ifFalse:[^ self]. |
|
898 |
||
899 |
entry1 := self shownList at:sel first. |
|
900 |
(entry1 := entry1 asFilename) exists ifFalse:[ |
|
901 |
self warn:'Oops - file is gone: ',entry1 pathName |
|
902 |
]. |
|
903 |
entry2 := self shownList at:sel second. |
|
904 |
(entry2 := entry2 asFilename) exists ifFalse:[ |
|
905 |
self warn:'Oops - file is gone: ',entry2 pathName |
|
906 |
]. |
|
907 |
masterApplication openDiffViewOn:entry1 and:entry2 |
|
908 |
! |
|
909 |
||
3892 | 910 |
doSearch |
16574 | 911 |
|namePatterns excludedNamePatterns contentsPattern notContentsPattern |
912 |
dir dirs fn fileToCompareAgainst ignoreCaseInName ignoreCaseInExcludedName |
|
11423 | 913 |
ignoreCaseInContents ignoreCaseInNotContents| |
3892 | 914 |
|
915 |
"/ self changeExtentToSeeSearchResult. |
|
916 |
||
917 |
dir := self searchDirectoryHolder value. |
|
918 |
dir isNil ifTrue:[ |
|
16574 | 919 |
Dialog warn:(resources string:'Missing directory name'). |
3892 | 920 |
^ self. |
921 |
]. |
|
16608 | 922 |
dir asString includesMatchCharacters ifTrue:[ |
16574 | 923 |
dirs := Filename filesMatchingGLOB:dir. |
924 |
dirs isEmpty ifTrue:[ |
|
925 |
Dialog warn:(resources string:'No matching directory: ''%1''' with:dir allBold). |
|
926 |
^ self. |
|
927 |
]. |
|
928 |
] ifFalse:[ |
|
929 |
dir asFilename exists ifFalse:[ |
|
930 |
Dialog warn:(resources string:'No such directory: ''%1''' with:dir allBold). |
|
931 |
^ self. |
|
932 |
]. |
|
933 |
dirs := { dir } |
|
3892 | 934 |
]. |
6442 | 935 |
|
13920 | 936 |
LastShowUnreadableFilesAndDirectories := showUnreadableFilesAndDirectoriesHolder value. |
10441 | 937 |
LastSearchIgnoredCaseInFilename := ignoreCaseInName := self ignoreCaseInName value. |
938 |
LastSearchIgnoredCaseInExcludedFilename := ignoreCaseInExcludedName := self ignoreCaseInExcludedName value. |
|
939 |
LastSearchIgnoredCaseInContents := ignoreCaseInContents := self ignoreCaseInContents value. |
|
11423 | 940 |
ignoreCaseInNotContents := self ignoreCaseInNotContents value. |
6442 | 941 |
|
11101 | 942 |
self stopSearchTaskOrAbort. |
3892 | 943 |
|
10441 | 944 |
namePatterns := self namePatternsFor:(self namePatternHolder value) ignoringCase:ignoreCaseInName. |
945 |
excludedNamePatterns := self namePatternsFor:(self excludedNamePatternHolder value) ignoringCase:ignoreCaseInExcludedName. |
|
946 |
||
3892 | 947 |
contentsPattern := self contentsPatternHolder value. |
948 |
contentsPattern size == 0 ifTrue:[ |
|
949 |
contentsPattern := nil |
|
950 |
] ifFalse:[ |
|
8330 | 951 |
self class addToSearchStringHistory:contentsPattern. |
10441 | 952 |
ignoreCaseInContents ifTrue:[ |
3892 | 953 |
contentsPattern := contentsPattern asLowercase |
8330 | 954 |
]. |
3892 | 955 |
]. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
956 |
notContentsPattern := self notContentsPatternHolder value. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
957 |
notContentsPattern size == 0 ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
958 |
notContentsPattern := nil |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
959 |
] ifFalse:[ |
11423 | 960 |
ignoreCaseInNotContents ifTrue:[ |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
961 |
notContentsPattern := notContentsPattern asLowercase |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
962 |
] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
963 |
]. |
5787 | 964 |
searchForSameContents value ifTrue:[ |
965 |
fileToCompareAgainst := (self sameContentsAsHolder value ? '') withoutSeparators. |
|
966 |
fileToCompareAgainst isEmpty ifTrue:[ |
|
967 |
fileToCompareAgainst := nil. |
|
968 |
] ifFalse:[ |
|
969 |
fileToCompareAgainst includesMatchCharacters ifFalse:[ |
|
16574 | 970 |
(fn := fileToCompareAgainst asFilename) exists ifFalse:[ |
18877 | 971 |
Dialog warn:'No such file: %1' with:fileToCompareAgainst allBold. |
5787 | 972 |
^ self. |
973 |
]. |
|
16574 | 974 |
fn isReadable ifFalse:[ |
18877 | 975 |
Dialog warn:'Cannot read: %1' with:fileToCompareAgainst allBold. |
5787 | 976 |
^ self. |
977 |
] |
|
5768 | 978 |
]. |
5726 | 979 |
]. |
5723 | 980 |
]. |
981 |
||
11101 | 982 |
self |
983 |
startSearchTask:[ |
|
984 |
self changeInformationTo:'Find File ' , '- searching ' toTab:true. |
|
985 |
self |
|
986 |
doFindFileNamed:namePatterns |
|
987 |
directories:(self searchDirectories value) |
|
988 |
ignoreCaseInName:ignoreCaseInName |
|
989 |
excludeFilesNamed:excludedNamePatterns |
|
990 |
ignoreCaseInExcludedName:ignoreCaseInExcludedName |
|
991 |
containingString:contentsPattern |
|
992 |
ignoreCaseInContents:ignoreCaseInContents |
|
993 |
notContainingString:notContentsPattern |
|
11423 | 994 |
ignoreCaseInNotContents:ignoreCaseInNotContents |
11101 | 995 |
sameContentsAsFile:fileToCompareAgainst |
996 |
sameContentsAs:nil |
|
16574 | 997 |
in:dirs. |
5770 | 998 |
|
11101 | 999 |
] |
16574 | 1000 |
name:('FindFile[', dir asFilename baseName, ']') |
5770 | 1001 |
|
11423 | 1002 |
"Modified: / 16-03-2012 / 09:37:13 / cg" |
18877 | 1003 |
"Modified: / 10-07-2019 / 18:26:13 / Claus Gittinger" |
3892 | 1004 |
! |
1005 |
||
7323 | 1006 |
fileInInBrowser |
1007 |
|sel entry application| |
|
1008 |
||
1009 |
sel := self selectionHolder value. |
|
1010 |
(sel notEmptyOrNil) ifTrue:[ |
|
1011 |
entry := self shownList at:sel first. |
|
1012 |
entry asFilename exists ifFalse:[ ^ self]. |
|
15214 | 1013 |
|
7323 | 1014 |
application := targetApplication ? self masterApplication. |
1015 |
application notNil ifTrue:[ |
|
1016 |
application fileIn:(entry asFilename). |
|
1017 |
]. |
|
1018 |
]. |
|
1019 |
||
1020 |
"Created: / 20-09-2006 / 14:30:37 / cg" |
|
1021 |
! |
|
1022 |
||
10441 | 1023 |
namePatternsFor:namePatternArg ignoringCase:ignoringCase |
1024 |
|namePattern| |
|
1025 |
||
1026 |
namePattern := namePatternArg. |
|
1027 |
namePattern size == 0 ifTrue:[ |
|
1028 |
^ nil |
|
1029 |
]. |
|
1030 |
ignoringCase ifTrue:[ |
|
1031 |
namePattern := namePattern asLowercase |
|
1032 |
]. |
|
1033 |
^ (namePattern asCollectionOfSubstringsSeparatedBy:$;) |
|
1034 |
collect:[:each | each withoutSeparators]. |
|
1035 |
||
1036 |
"Created: / 03-08-2011 / 18:19:20 / cg" |
|
1037 |
! |
|
1038 |
||
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1039 |
removeFilesFromResultList:listOfFiles |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1040 |
|list| |
3892 | 1041 |
|
5864 | 1042 |
list := self shownList. |
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1043 |
(listOfFiles notEmptyOrNil) ifTrue:[ |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1044 |
listOfFiles reverseDo:[: key | |
3892 | 1045 |
list removeAtIndex:key |
1046 |
] |
|
1047 |
]. |
|
11474
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1048 |
|
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1049 |
"Created: / 29-03-2012 / 10:04:58 / cg" |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1050 |
! |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1051 |
|
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1052 |
removeSelectedFilesFromResultList |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1053 |
self removeFilesFromResultList:(self selectionHolder value) |
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1054 |
|
99b9dcfbcc4a
added: #removeFilesFromResultList:
Claus Gittinger <cg@exept.de>
parents:
11473
diff
changeset
|
1055 |
"Modified: / 29-03-2012 / 10:05:11 / cg" |
3892 | 1056 |
! |
1057 |
||
5859 | 1058 |
showMatchedFiles:aBoolean |
1059 |
aBoolean ifTrue:[ |
|
5864 | 1060 |
self shownListHolder valueHolder:(self matchedFilesList) |
5859 | 1061 |
] ifFalse:[ |
5864 | 1062 |
self shownListHolder valueHolder:(self resultList) |
5859 | 1063 |
]. |
16826 | 1064 |
! |
1065 |
||
1066 |
touchAllFiles |
|
1067 |
|files| |
|
1068 |
||
1069 |
files := self shownList copy. |
|
1070 |
self touchFiles:files. |
|
1071 |
! |
|
1072 |
||
1073 |
touchFiles:colOfFiles |
|
1074 |
"touch current selected files/directories |
|
1075 |
" |
|
1076 |
colOfFiles asSet do:[:each | |
|
1077 |
OperatingSystem executeCommand:('touch %1' bindWith:each asFilename pathName). |
|
1078 |
]. |
|
1079 |
! |
|
1080 |
||
1081 |
touchSelectedFiles |
|
1082 |
|sel files| |
|
1083 |
||
1084 |
sel := self selectionHolder value. |
|
1085 |
sel isEmptyOrNil ifTrue:[^ self]. |
|
1086 |
||
1087 |
files := sel collect:[:idx | self shownList at:idx]. |
|
1088 |
self touchFiles:files. |
|
3892 | 1089 |
! ! |
1090 |
||
12778 | 1091 |
!FindFileApplication methodsFor:'actions-CVS'! |
1092 |
||
1093 |
commitSelectedFilesToCVS |
|
1094 |
|sel files| |
|
1095 |
||
1096 |
sel := self selectionHolder value. |
|
1097 |
files := sel collect:[:idx | (self shownList at:idx) asFilename ]. |
|
1098 |
masterApplication commitFilesToCVS:files |
|
1099 |
! |
|
1100 |
||
1101 |
deleteSelectedFilesAndCVSContainers |
|
1102 |
|sel files| |
|
1103 |
||
1104 |
sel := self selectionHolder value. |
|
1105 |
files := sel collect:[:idx | (self shownList at:idx) asFilename ]. |
|
1106 |
masterApplication removeFilesAndCVSContainers:files |
|
1107 |
! ! |
|
1108 |
||
3892 | 1109 |
!FindFileApplication methodsFor:'aspects'! |
1110 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1111 |
canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1112 |
"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
|
1113 |
- not under MSDOS |
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 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1116 |
^ 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
|
1117 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1118 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1119 |
canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1120 |
"locate command is much faster, but: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1121 |
- only if searching recursively, |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1122 |
- no case ignore |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1123 |
- no contents matching |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1124 |
" |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1125 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1126 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'locate' ] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1127 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1128 |
|
3892 | 1129 |
contentsPatternHolder |
1130 |
||
1131 |
contentsPatternHolder isNil ifTrue:[ |
|
1132 |
contentsPatternHolder := nil asValue. |
|
18630 | 1133 |
self class searchStringHistory size ~~ 0 ifTrue:[ |
8330 | 1134 |
contentsPatternHolder value:(self class searchStringHistory first). |
1135 |
]. |
|
3892 | 1136 |
]. |
1137 |
^ contentsPatternHolder. |
|
18630 | 1138 |
|
1139 |
"Modified: / 01-03-2019 / 15:43:39 / Claus Gittinger" |
|
3892 | 1140 |
! |
1141 |
||
6330 | 1142 |
enableFileSizeFilter |
1143 |
enableFileSizeFilter isNil ifTrue:[ |
|
1144 |
enableFileSizeFilter := false asValue. |
|
1145 |
]. |
|
1146 |
^ enableFileSizeFilter. |
|
1147 |
! |
|
1148 |
||
1149 |
enableFileSizeFilterAndNotSearchForSameContents |
|
1150 |
^ BlockValue forLogical:self notSearchForSameContents and:self enableFileSizeFilter |
|
1151 |
! |
|
1152 |
||
11473 | 1153 |
enableModificationTimeFilter |
1154 |
enableModificationTimeFilter isNil ifTrue:[ |
|
1155 |
enableModificationTimeFilter := false asValue. |
|
1156 |
]. |
|
1157 |
^ enableModificationTimeFilter. |
|
1158 |
||
1159 |
"Created: / 28-03-2012 / 23:11:58 / cg" |
|
1160 |
! |
|
1161 |
||
10441 | 1162 |
excludedNamePatternHolder |
1163 |
excludedNamePatternHolder isNil ifTrue:[ |
|
1164 |
excludedNamePatternHolder := '' asValue. |
|
1165 |
]. |
|
1166 |
^ excludedNamePatternHolder. |
|
1167 |
||
1168 |
"Created: / 03-08-2011 / 18:03:14 / cg" |
|
1169 |
! |
|
1170 |
||
6330 | 1171 |
fileSizeHolder |
1172 |
fileSizeHolder isNil ifTrue:[ |
|
1173 |
fileSizeHolder := 0 asValue. |
|
1174 |
]. |
|
1175 |
^ fileSizeHolder. |
|
1176 |
! |
|
1177 |
||
1178 |
fileSizeOperatorHolder |
|
1179 |
fileSizeOperatorHolder isNil ifTrue:[ |
|
1180 |
fileSizeOperatorHolder := '>' asValue. |
|
1181 |
]. |
|
1182 |
^ fileSizeOperatorHolder. |
|
1183 |
! |
|
1184 |
||
1185 |
fileSizeUnitHolder |
|
1186 |
fileSizeUnitHolder isNil ifTrue:[ |
|
1187 |
fileSizeUnitHolder := 'b' asValue. |
|
1188 |
]. |
|
1189 |
^ fileSizeUnitHolder. |
|
1190 |
! |
|
1191 |
||
3892 | 1192 |
ignoreCaseInContents |
1193 |
ignoreCaseInContents isNil ifTrue:[ |
|
10441 | 1194 |
ignoreCaseInContents := (LastSearchIgnoredCaseInContents notNil |
1195 |
ifTrue:[ LastSearchIgnoredCaseInContents ] |
|
1196 |
ifFalse:[ TextView lastSearchIgnoredCase ? true]) asValue. |
|
3892 | 1197 |
]. |
1198 |
^ ignoreCaseInContents. |
|
10441 | 1199 |
|
1200 |
"Modified: / 03-08-2011 / 18:05:02 / cg" |
|
1201 |
! |
|
1202 |
||
1203 |
ignoreCaseInExcludedName |
|
1204 |
||
1205 |
ignoreCaseInExcludedName isNil ifTrue:[ |
|
1206 |
ignoreCaseInExcludedName := (LastSearchIgnoredCaseInExcludedFilename notNil |
|
1207 |
ifTrue:[ LastSearchIgnoredCaseInExcludedFilename ] |
|
1208 |
ifFalse:[ OperatingSystem caseSensitiveFilenames not]) asValue. |
|
1209 |
]. |
|
1210 |
^ ignoreCaseInExcludedName. |
|
1211 |
||
1212 |
"Created: / 03-08-2011 / 18:03:38 / cg" |
|
3892 | 1213 |
! |
1214 |
||
1215 |
ignoreCaseInName |
|
1216 |
ignoreCaseInName isNil ifTrue:[ |
|
10441 | 1217 |
ignoreCaseInName := (LastSearchIgnoredCaseInFilename notNil |
1218 |
ifTrue:[LastSearchIgnoredCaseInFilename] |
|
1219 |
ifFalse:[ OperatingSystem caseSensitiveFilenames not ]) asValue. |
|
3892 | 1220 |
]. |
1221 |
^ ignoreCaseInName. |
|
10441 | 1222 |
|
1223 |
"Modified (format): / 03-08-2011 / 18:05:49 / cg" |
|
3892 | 1224 |
! |
1225 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1226 |
ignoreCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1227 |
ignoreCaseInNotContents isNil ifTrue:[ |
6442 | 1228 |
ignoreCaseInNotContents := (LastSearchIgnoredCaseInContents |
1229 |
? TextView lastSearchIgnoredCase |
|
1230 |
? true) asValue. |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1231 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1232 |
^ ignoreCaseInNotContents. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1233 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1234 |
|
11473 | 1235 |
modificationTimeHolder |
1236 |
modificationTimeHolder isNil ifTrue:[ |
|
1237 |
modificationTimeHolder := (Timestamp now subtractDays:1) asValue. |
|
1238 |
]. |
|
1239 |
^ modificationTimeHolder. |
|
1240 |
||
1241 |
"Created: / 28-03-2012 / 23:08:25 / cg" |
|
1242 |
! |
|
1243 |
||
1244 |
modificationTimeOperatorHolder |
|
1245 |
modificationTimeOperatorHolder isNil ifTrue:[ |
|
1246 |
modificationTimeOperatorHolder := 'after' asValue. |
|
16810 | 1247 |
modificationTimeOperatorHolder onChangeSend:#modificationTimeOperatorChanged to:self. |
11473 | 1248 |
]. |
1249 |
^ modificationTimeOperatorHolder. |
|
1250 |
||
1251 |
"Created: / 28-03-2012 / 23:04:44 / cg" |
|
1252 |
! |
|
1253 |
||
16810 | 1254 |
modificationTimeOperatorIndexHolder |
1255 |
modificationTimeOperatorIndexHolder isNil ifTrue:[ |
|
1256 |
modificationTimeOperatorIndexHolder := 1 asValue. |
|
1257 |
modificationTimeOperatorIndexHolder onChangeSend:#modificationTimeOperatorChanged to:self. |
|
1258 |
]. |
|
1259 |
^ modificationTimeOperatorIndexHolder. |
|
1260 |
||
1261 |
"Created: / 28-03-2012 / 23:04:44 / cg" |
|
1262 |
! |
|
1263 |
||
1264 |
modificationTimeOperatorLabelList |
|
1265 |
^ self modificationTimeOperatorSpecList collect:#first |
|
1266 |
! |
|
1267 |
||
1268 |
modificationTimeOperatorSpecList |
|
1269 |
^ #( |
|
1270 |
('before' #before) |
|
1271 |
('after' #after) |
|
1272 |
('in day' #inDay) |
|
1273 |
('in month' #inMonth) |
|
1274 |
('in year' #inYear) |
|
1275 |
) |
|
1276 |
! |
|
1277 |
||
1278 |
modificationTimeOperatorValueList |
|
1279 |
^ self modificationTimeOperatorSpecList collect:#second |
|
1280 |
! |
|
1281 |
||
3892 | 1282 |
namePatternHolder |
1283 |
||
1284 |
namePatternHolder isNil ifTrue:[ |
|
1285 |
namePatternHolder := '*' asValue. |
|
1286 |
]. |
|
1287 |
^ namePatternHolder. |
|
1288 |
! |
|
1289 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1290 |
notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1291 |
notContentsPatternHolder isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1292 |
notContentsPatternHolder := nil asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1293 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1294 |
^ notContentsPatternHolder. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1295 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1296 |
|
3892 | 1297 |
notSearchForSameContents |
5743 | 1298 |
^ BlockValue forLogicalNot:self searchForSameContents |
3892 | 1299 |
! |
1300 |
||
5859 | 1301 |
notShowingMatchedFiles |
5865 | 1302 |
^ self shownList == self resultList |
5859 | 1303 |
! |
1304 |
||
5723 | 1305 |
rememberInCache |
1306 |
rememberInCache isNil ifTrue:[ |
|
5859 | 1307 |
rememberInCache := (LastRememberInCache ? false) asValue. |
5723 | 1308 |
]. |
1309 |
^ rememberInCache. |
|
1310 |
! |
|
1311 |
||
1312 |
sameContentsAsHolder |
|
1313 |
|sel| |
|
1314 |
||
1315 |
sameContentsAsHolder isNil ifTrue:[ |
|
1316 |
sameContentsAsHolder := ValueHolder new. |
|
1317 |
masterApplication notNil ifTrue:[ |
|
1318 |
sel := masterApplication currentSelectedFiles. |
|
18630 | 1319 |
sel size ~~ 0 ifTrue:[ |
5723 | 1320 |
sameContentsAsHolder value:(sel first asFilename pathName). |
1321 |
]. |
|
1322 |
]. |
|
1323 |
]. |
|
1324 |
^ sameContentsAsHolder. |
|
18630 | 1325 |
|
1326 |
"Modified: / 01-03-2019 / 15:43:43 / Claus Gittinger" |
|
5723 | 1327 |
! |
1328 |
||
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1329 |
searchDirectories |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1330 |
searchDirectories isNil ifTrue:[ |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1331 |
searchDirectories := false asValue. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1332 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1333 |
^ searchDirectories. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1334 |
! |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1335 |
|
3892 | 1336 |
searchDirectoryHolder |
1337 |
||
1338 |
searchDirectoryHolder isNil ifTrue:[ |
|
1339 |
searchDirectoryHolder := ValueHolder new. |
|
1340 |
]. |
|
1341 |
^ searchDirectoryHolder. |
|
1342 |
! |
|
1343 |
||
17751 | 1344 |
searchForBinaryContentsHolder |
1345 |
searchForBinaryContentsHolder isNil ifTrue:[ |
|
1346 |
searchForBinaryContentsHolder := (LastSearchForBinaryContents ? false) asValue. |
|
1347 |
]. |
|
1348 |
^ searchForBinaryContentsHolder. |
|
1349 |
||
1350 |
"Created: / 12-11-2017 / 17:35:56 / cg" |
|
1351 |
! |
|
1352 |
||
5743 | 1353 |
searchForSameContents |
1354 |
searchForSameContents isNil ifTrue:[ |
|
1355 |
searchForSameContents := false asValue. |
|
1356 |
]. |
|
1357 |
^ searchForSameContents. |
|
1358 |
! |
|
1359 |
||
5726 | 1360 |
searchOnlyInCache |
1361 |
searchOnlyInCache isNil ifTrue:[ |
|
1362 |
searchOnlyInCache := false asValue. |
|
1363 |
]. |
|
1364 |
^ searchOnlyInCache. |
|
1365 |
! |
|
1366 |
||
13920 | 1367 |
showUnreadableFilesAndDirectoriesHolder |
1368 |
showUnreadableFilesAndDirectoriesHolder isNil ifTrue:[ |
|
1369 |
showUnreadableFilesAndDirectoriesHolder := (LastShowUnreadableFilesAndDirectories ? false) asValue. |
|
1370 |
]. |
|
1371 |
^ showUnreadableFilesAndDirectoriesHolder. |
|
1372 |
! |
|
1373 |
||
5859 | 1374 |
showingMatchedFiles |
5865 | 1375 |
^ self shownList == self matchedFilesList |
5859 | 1376 |
! |
1377 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1378 |
useGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1379 |
useGrep isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1380 |
useGrep := false asValue. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1381 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1382 |
^ useGrep. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1383 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1384 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1385 |
useLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1386 |
useLocate isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1387 |
useLocate := false asValue. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1388 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1389 |
^ useLocate. |
3892 | 1390 |
! ! |
1391 |
||
16810 | 1392 |
!FindFileApplication methodsFor:'change & update'! |
1393 |
||
1394 |
modificationTimeOperatorChanged |
|
1395 |
|timeEditField converter realModel idx operator| |
|
1396 |
||
1397 |
timeEditField := (self componentAt:'ModifiedEntryField'). |
|
1398 |
converter := timeEditField model. |
|
1399 |
realModel := converter model. |
|
1400 |
self assert:(self modificationTimeHolder == realModel). |
|
1401 |
idx := self modificationTimeOperatorIndexHolder value. |
|
1402 |
operator := self modificationTimeOperatorValueList at:idx. |
|
1403 |
||
1404 |
((operator == #after) or:[operator = #before]) ifTrue:[ |
|
1405 |
realModel setValue:(realModel value asTimestamp). |
|
1406 |
converter timeOfClass:Timestamp withFormat:nil orDefault:Timestamp now |
|
1407 |
] ifFalse:[ |
|
1408 |
operator = #inDay ifTrue:[ |
|
1409 |
realModel setValue:(realModel value asDate). |
|
1410 |
converter timeOfClass:Date withFormat:'%y-%m-%d' orDefault:Date today |
|
1411 |
] ifFalse:[ |
|
1412 |
operator = #inMonth ifTrue:[ |
|
1413 |
realModel setValue:(realModel value asDate). |
|
1414 |
converter monthAndYear |
|
1415 |
] ifFalse:[ |
|
1416 |
operator = #inYear ifTrue:[ |
|
1417 |
realModel setValue:(realModel value asDate). |
|
1418 |
converter year |
|
1419 |
] ifFalse:[ |
|
1420 |
self halt. |
|
1421 |
]. |
|
1422 |
]. |
|
1423 |
]. |
|
1424 |
]. |
|
1425 |
realModel changed. |
|
1426 |
! ! |
|
1427 |
||
3892 | 1428 |
!FindFileApplication methodsFor:'private'! |
1429 |
||
1430 |
changeExtentToSeeSearchResult |
|
1431 |
||
1432 |
| extent window| |
|
1433 |
||
1434 |
expanded isNil ifTrue:[ |
|
1435 |
window := self builder window. |
|
9536
ea60487ceeee
changed: #changeExtentToSeeSearchResult
Claus Gittinger <cg@exept.de>
parents:
9475
diff
changeset
|
1436 |
window notNil ifTrue:[ |
3892 | 1437 |
window := window topView. |
1438 |
extent := window extent. |
|
1439 |
window extent:((extent x) @ (extent y + 300)). |
|
1440 |
expanded := true. |
|
1441 |
window containerChangedSize. |
|
1442 |
]. |
|
1443 |
]. |
|
9536
ea60487ceeee
changed: #changeExtentToSeeSearchResult
Claus Gittinger <cg@exept.de>
parents:
9475
diff
changeset
|
1444 |
|
ea60487ceeee
changed: #changeExtentToSeeSearchResult
Claus Gittinger <cg@exept.de>
parents:
9475
diff
changeset
|
1445 |
"Modified: / 08-08-2010 / 14:42:40 / cg" |
3892 | 1446 |
! ! |
1447 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1448 |
!FindFileApplication methodsFor:'private - searching'! |
3892 | 1449 |
|
5856 | 1450 |
cachedFileSizeOf:aFilenameString |
1451 |
|cache cacheLine fileSize| |
|
1452 |
||
1453 |
cache := self contentsInfoCache. |
|
1454 |
cache isNil ifTrue:[ |
|
5859 | 1455 |
fileSize := aFilenameString asFilename fileSize |
5856 | 1456 |
] ifFalse:[ |
5859 | 1457 |
ContentsInfoCacheAccessLock critical:[ |
1458 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1459 |
cacheLine isNil ifTrue:[ |
|
1460 |
cache at:aFilenameString put:(cacheLine := Array new:2). |
|
1461 |
] ifFalse:[ |
|
1462 |
fileSize := (cacheLine at:1). |
|
1463 |
]. |
|
5856 | 1464 |
|
5859 | 1465 |
fileSize isNil ifTrue:[ |
1466 |
fileSize := aFilenameString asFilename fileSize. |
|
1467 |
cacheLine at:1 put:fileSize. |
|
1468 |
]. |
|
1469 |
]. |
|
5856 | 1470 |
]. |
1471 |
^ fileSize |
|
1472 |
! |
|
1473 |
||
1474 |
cachedHashValueOfFile:aFilenameString |
|
1475 |
|cache cacheLine hashValue| |
|
1476 |
||
1477 |
cache := self contentsInfoCache. |
|
1478 |
cache isNil ifTrue:[ |
|
5859 | 1479 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename |
5856 | 1480 |
] ifFalse:[ |
5859 | 1481 |
ContentsInfoCacheAccessLock critical:[ |
1482 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1483 |
cacheLine isNil ifTrue:[ |
|
1484 |
cache at:aFilenameString put:(Array new:2). |
|
1485 |
] ifFalse:[ |
|
1486 |
hashValue := (cacheLine at:2). |
|
1487 |
]. |
|
5856 | 1488 |
|
5859 | 1489 |
hashValue isNil ifTrue:[ |
1490 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename. |
|
1491 |
cacheLine at:2 put:hashValue. |
|
1492 |
]. |
|
1493 |
]. |
|
5856 | 1494 |
]. |
1495 |
^ hashValue |
|
1496 |
! |
|
1497 |
||
1498 |
contentsInfoCache |
|
6107 | 1499 |
contentsInfoCache isNil ifTrue:[ |
1500 |
ContentsInfoCache isNil ifTrue:[ |
|
1501 |
ContentsInfoCache := Dictionary new. |
|
1502 |
ContentsInfoCacheAccessLock := Semaphore forMutualExclusion. |
|
1503 |
]. |
|
1504 |
contentsInfoCache := ContentsInfoCache |
|
5856 | 1505 |
]. |
6107 | 1506 |
^ contentsInfoCache |
5856 | 1507 |
! |
1508 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1509 |
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
|
1510 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1511 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1512 |
sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory |
3892 | 1513 |
|
10441 | 1514 |
"/ only for backward compatibility... |
1515 |
^ self |
|
1516 |
doFindFileNamed:namePatterns directories:searchDirectories ignoreCaseInName:ignCaseInName |
|
1517 |
excludeFilesNamed:'' ignoreCaseInExcludedName:false |
|
1518 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
|
1519 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
|
1520 |
sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory |
|
1521 |
||
1522 |
"Modified: / 03-08-2011 / 18:16:42 / cg" |
|
1523 |
! |
|
1524 |
||
1525 |
doFindFileNamed:namePatterns directories:searchDirectories ignoreCaseInName:ignCaseInName |
|
1526 |
excludeFilesNamed:excludedNamePatterns ignoreCaseInExcludedName:ignoreCaseInExcludedName |
|
1527 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
|
1528 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
|
16574 | 1529 |
sameContentsAsFile:filenameToCompareContentsOrNil |
1530 |
sameContentsAs:bytesToCompareContentsOrNil |
|
1531 |
in:aDirectoryOrCollectionOfDirectories |
|
10441 | 1532 |
|
15217 | 1533 |
"the main workhorse for searching files. |
1534 |
Creates optimized search blocks, depending on how we search, |
|
1535 |
and passes these to the recursive directory walker. |
|
1536 |
(got too big, and may need some splitting/refactoring" |
|
1537 |
||
16574 | 1538 |
|theSingleDirectory lines contentsToCompare resultList inStream |
5601 | 1539 |
doesFileMatch contentsString notContentsString check checkNot |
11473 | 1540 |
grepCommand nameMatch nameExcludedMatch realNameMatch |
1541 |
fileSizesToSearchFor filesToSearchFor fileMD5sToSearchFor |
|
18457 | 1542 |
setOfFilesToSearchFor remember cache fn easyCheck |
17751 | 1543 |
searchForBinaryContents| |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1544 |
|
17751 | 1545 |
searchForBinaryContents := self searchForBinaryContentsHolder value. |
1546 |
||
16574 | 1547 |
(aDirectoryOrCollectionOfDirectories isFilename |
1548 |
or:[aDirectoryOrCollectionOfDirectories isString]) ifTrue:[ |
|
1549 |
theSingleDirectory := aDirectoryOrCollectionOfDirectories asFilename |
|
1550 |
] ifFalse:[ |
|
1551 |
(aDirectoryOrCollectionOfDirectories size == 1) ifTrue:[ |
|
1552 |
theSingleDirectory := aDirectoryOrCollectionOfDirectories first asFilename |
|
1553 |
]. |
|
1554 |
]. |
|
1555 |
||
1556 |
"/ dir := aDirectory asFilename. |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1557 |
contentsString := contentsStringArg. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1558 |
notContentsString := notContentsStringArg. |
17751 | 1559 |
|
1560 |
searchForBinaryContents ifTrue:[ |
|
1561 |
contentsString notEmptyOrNil ifTrue:[ |
|
1562 |
contentsString := (contentsStringArg asCollectionOfWords |
|
1563 |
collect:[:s | Integer readFrom:s radix:16] as:ByteArray) asString. |
|
1564 |
]. |
|
1565 |
notContentsString notEmptyOrNil ifTrue:[ |
|
1566 |
notContentsString := (notContentsStringArg asCollectionOfWords |
|
1567 |
collect:[:s | Integer readFrom:s radix:16] as:ByteArray) asString. |
|
1568 |
]. |
|
1569 |
] ifFalse:[ |
|
1570 |
(contentsString notEmptyOrNil and:[ ignCaseInContents ]) ifTrue:[ |
|
1571 |
contentsString := contentsString asLowercase |
|
1572 |
]. |
|
1573 |
(notContentsString notEmptyOrNil and:[ ignCaseInNotContents ]) ifTrue:[ |
|
1574 |
notContentsString := notContentsString asLowercase |
|
1575 |
]. |
|
6183
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1576 |
]. |
12385 | 1577 |
filenameToCompareContentsOrNil notEmptyOrNil ifTrue:[ |
5768 | 1578 |
fileSizesToSearchFor := OrderedCollection new. |
1579 |
filesToSearchFor := OrderedCollection new. |
|
1580 |
fileMD5sToSearchFor := OrderedCollection new. |
|
1581 |
||
1582 |
filenameToCompareContentsOrNil includesMatchCharacters ifTrue:[ |
|
16574 | 1583 |
|dir| |
1584 |
||
5768 | 1585 |
dir := filenameToCompareContentsOrNil asFilename. |
1586 |
[dir pathName includesMatchCharacters] whileTrue:[ |
|
1587 |
dir := dir directory |
|
1588 |
]. |
|
18457 | 1589 |
dir recursiveDirectoryContentsAsFilenamesDo:[:fn | |
5770 | 1590 |
(filenameToCompareContentsOrNil match:fn name) ifTrue:[ |
18457 | 1591 |
fn isRegularFile ifTrue:[ |
5856 | 1592 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5847 | 1593 |
filesToSearchFor add:(fn name). |
5856 | 1594 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5847 | 1595 |
] |
5768 | 1596 |
] |
1597 |
]. |
|
1598 |
] ifFalse:[ |
|
1599 |
fn := filenameToCompareContentsOrNil asFilename. |
|
5856 | 1600 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5768 | 1601 |
filesToSearchFor add:(fn pathName). |
5856 | 1602 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5768 | 1603 |
]. |
1604 |
||
5859 | 1605 |
remember := LastRememberInCache := self rememberInCache value. |
5723 | 1606 |
remember ifTrue:[ |
5856 | 1607 |
cache := self contentsInfoCache. |
5723 | 1608 |
]. |
5866 | 1609 |
setOfFilesToSearchFor := filesToSearchFor asSet. |
1610 |
]. |
|
16574 | 1611 |
|
10441 | 1612 |
"/ dirSearchedRelative := (dir name) copyFrom:(self searchDirectoryHolder value asString size + 1). |
1613 |
"/ dirSearchedRelative notEmpty ifTrue:[ |
|
1614 |
"/ self changeInformationTo:('Find File - searching %1' bindWith:dirSearchedRelative) toTab:false. |
|
1615 |
"/ ] ifFalse:[ |
|
1616 |
self changeInformationTo:'Find File - searching' toTab:false. |
|
1617 |
"/ ]. |
|
3892 | 1618 |
|
5859 | 1619 |
resultList := self resultList. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1620 |
|
12385 | 1621 |
filenameToCompareContentsOrNil notEmptyOrNil ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1622 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1623 |
[:f | |
5859 | 1624 |
|contentsMatches mustValidateExistance |
1625 |
fileMD5 fileName fileSize cacheLine idxInList matchedFile| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1626 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1627 |
"/ contents compare ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1628 |
contentsMatches := false. |
5771 | 1629 |
fileName := f name. |
5859 | 1630 |
(setOfFilesToSearchFor includes:fileName) ifFalse:[ |
5850 | 1631 |
mustValidateExistance := false. |
5856 | 1632 |
|
5727 | 1633 |
cache notNil ifTrue:[ |
5859 | 1634 |
ContentsInfoCacheAccessLock critical:[ |
1635 |
cacheLine := cache at:fileName ifAbsent:nil. |
|
1636 |
cacheLine notNil ifTrue:[ |
|
1637 |
fileSize := cacheLine at:1. |
|
1638 |
fileMD5 := cacheLine at:2. |
|
1639 |
mustValidateExistance := true. |
|
1640 |
]. |
|
5727 | 1641 |
]. |
5723 | 1642 |
]. |
5850 | 1643 |
|
5723 | 1644 |
fileSize isNil ifTrue:[ |
1645 |
fileSize := f fileSize. |
|
1646 |
]. |
|
1647 |
remember ifTrue:[ |
|
5859 | 1648 |
ContentsInfoCacheAccessLock critical:[ |
1649 |
cacheLine := cache at:fileName ifAbsentPut:[Array new:2]. |
|
1650 |
cacheLine at:1 put:fileSize. |
|
1651 |
] |
|
5723 | 1652 |
]. |
5768 | 1653 |
(idxInList := fileSizesToSearchFor indexOf:fileSize) ~~ 0 ifTrue:[ |
5723 | 1654 |
fileMD5 isNil ifTrue:[ |
5850 | 1655 |
OpenError handle:[:ex | |
1656 |
ObjectMemory garbageCollect. |
|
1657 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1658 |
] do:[ |
|
1659 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1660 |
]. |
|
5723 | 1661 |
remember ifTrue:[ |
1662 |
cacheLine at:2 put:fileMD5 |
|
1663 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1664 |
]. |
5768 | 1665 |
contentsMatches := (fileMD5 = (fileMD5sToSearchFor at:idxInList)). |
5850 | 1666 |
contentsMatches ifTrue:[ |
1667 |
mustValidateExistance ifTrue:[ |
|
1668 |
fileName asFilename exists ifFalse:[ |
|
5859 | 1669 |
ContentsInfoCacheAccessLock critical:[ |
1670 |
cache removeKey:fileName. |
|
1671 |
]. |
|
5850 | 1672 |
contentsMatches := false. |
1673 |
]. |
|
5859 | 1674 |
]. |
1675 |
contentsMatches ifTrue:[ |
|
1676 |
matchedFile := filesToSearchFor at:idxInList. |
|
11106
86ac37a9a382
changed: #doFindFileNamed:directories:ignoreCaseInName:excludeFilesNamed:ignoreCaseInExcludedName:containingString:ignoreCaseInContents:notContainingString:ignoreCaseInNotContents:sameContentsAsFile:sameContentsAs:in:
Claus Gittinger <cg@exept.de>
parents:
11103
diff
changeset
|
1677 |
self matchedFilesList add:matchedFile. |
5859 | 1678 |
]. |
5850 | 1679 |
]. |
5723 | 1680 |
"/ contentsToCompare isNil ifTrue:[ |
1681 |
"/ filenameToCompareContentsOrNil fileSize < (512*1024) ifTrue:[ |
|
1682 |
"/ contentsToCompare := filenameToCompareContentsOrNil binaryContentsOfEntireFile |
|
1683 |
"/ ] |
|
1684 |
"/ ]. |
|
1685 |
"/ contentsToCompare isNil ifTrue:[ |
|
1686 |
"/ "/ too large - compare block-wise ... |
|
1687 |
"/ contentsMatches := (filenameToCompareContentsOrNil sameContentsAs:f). |
|
1688 |
"/ ] ifFalse:[ |
|
1689 |
"/ contentsMatches := contentsToCompare = (f binaryContentsOfEntireFile). |
|
1690 |
"/ ] |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1691 |
]. |
5773 | 1692 |
] ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1693 |
f isSymbolicLink ifTrue:[ |
5859 | 1694 |
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
|
1695 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1696 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1697 |
contentsMatches |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1698 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1699 |
] ifFalse:[ |
12385 | 1700 |
(contentsString isEmptyOrNil and:[notContentsString isEmptyOrNil]) ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1701 |
doesFileMatch := [:f | true]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1702 |
] ifFalse:[ |
17751 | 1703 |
searchForBinaryContents ifFalse:[ |
1704 |
(self canUseGrep and:[self useGrep value]) ifTrue:[ |
|
1705 |
(ignCaseInContents not and:[ignCaseInNotContents not]) ifTrue:[ |
|
1706 |
contentsString notEmptyOrNil ifTrue:[ |
|
1707 |
notContentsString notEmptyOrNil ifTrue:[ |
|
1708 |
grepCommand := '(grep "',contentsString,'" %1) && (grep -v "',notContentsString,'" %1)'. |
|
1709 |
] ifFalse:[ |
|
1710 |
grepCommand := 'grep "' , contentsString , '" %1'. |
|
1711 |
]. |
|
5601 | 1712 |
] ifFalse:[ |
17751 | 1713 |
grepCommand := 'grep -v "' , notContentsString , '" %1'. |
5601 | 1714 |
]. |
17751 | 1715 |
doesFileMatch := [:f | |cmd ret| |
18370 | 1716 |
bytesSearchedCount := bytesSearchedCount + f fileSize. |
17751 | 1717 |
cmd := grepCommand bindWith:f pathName. |
1718 |
ret := OperatingSystem executeCommand:cmd. |
|
1719 |
ret |
|
1720 |
]. |
|
1721 |
] |
|
1722 |
]. |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1723 |
]. |
17751 | 1724 |
|
5601 | 1725 |
doesFileMatch isNil ifTrue:[ |
12385 | 1726 |
contentsString notEmptyOrNil ifTrue:[ |
17751 | 1727 |
(searchForBinaryContents not and:[ignCaseInContents]) ifTrue:[ |
12339 | 1728 |
check := easyCheck := [:l | l includesString:contentsString caseSensitive:false] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1729 |
] ifFalse:[ |
12339 | 1730 |
check := easyCheck := [:l | l includesString:contentsString] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1731 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1732 |
]. |
12385 | 1733 |
notContentsString notEmptyOrNil ifTrue:[ |
17751 | 1734 |
(searchForBinaryContents not and:[ignCaseInNotContents]) ifTrue:[ |
12385 | 1735 |
checkNot := [:l | (l includesString:notContentsString caseSensitive:false)] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1736 |
] ifFalse:[ |
12385 | 1737 |
checkNot := [:l | (l includesString:notContentsString)] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1738 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1739 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1740 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1741 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1742 |
[:f | |
16186 | 1743 |
|realFile contentsMatches contentsNotMatches sz hugeFile bigFile isBadFile| |
10441 | 1744 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1745 |
"/ string search ... |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1746 |
contentsMatches := true. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1747 |
(f exists and:[f isReadable]) ifFalse:[ |
13920 | 1748 |
showUnreadableFilesAndDirectoriesHolder value ifTrue:[ |
18675 | 1749 |
resultList add: (('*** "',f pathName,'" skipped - unreadable or bad symbolic link ***') withColor:(Color darkRed)). |
13920 | 1750 |
]. |
13773 | 1751 |
contentsMatches := false. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1752 |
] ifTrue:[ |
16186 | 1753 |
isBadFile := false. |
1754 |
realFile := f. |
|
1755 |
f isSymbolicLink ifTrue:[ |
|
1756 |
realFile := f linkInfo linkTargetPath asFilename. |
|
1757 |
(realFile exists and:[realFile isReadable]) ifFalse:[ |
|
13920 | 1758 |
showUnreadableFilesAndDirectoriesHolder value ifTrue:[ |
18675 | 1759 |
resultList add: (('*** "',f pathName,'"->"',realFile pathName,'" skipped - unreadable or bad symbolic link destination ***') withColor:(Color darkRed)). |
13920 | 1760 |
]. |
13773 | 1761 |
contentsMatches := false. |
16186 | 1762 |
isBadFile := true. |
1763 |
]. |
|
1764 |
]. |
|
1765 |
isBadFile ifFalse:[ |
|
1766 |
realFile isDirectory ifTrue:[ |
|
1767 |
contentsMatches := false. |
|
1768 |
] ifFalse:[ |
|
1769 |
sz := realFile fileSize. |
|
1770 |
sz isNil ifTrue:[ |
|
1771 |
contentsMatches := false. |
|
1772 |
] ifFalse:[ |
|
1773 |
hugeFile := (sz ? 0) > (4024*1024). |
|
1774 |
bigFile := (sz ? 0) > (512*1024). |
|
15105 | 1775 |
|
16186 | 1776 |
hugeFile ifTrue:[ |
1777 |
showUnreadableFilesAndDirectoriesHolder value ifTrue:[ |
|
18675 | 1778 |
resultList add: (('*** ' , f pathName , ' skipped - too large ***') withColor:(Color darkRed)). |
16186 | 1779 |
]. |
1780 |
contentsMatches := false. |
|
1781 |
] ifFalse:[ |
|
15105 | 1782 |
Stream lineTooLongErrorSignal handle:[:ex | |
16186 | 1783 |
|cont| |
1784 |
||
1785 |
"/ "/ this typically happens, when a binary file is read linewise ... |
|
15105 | 1786 |
showUnreadableFilesAndDirectoriesHolder value ifTrue:[ |
18675 | 1787 |
resultList add: (('*** ' , f pathName , ' skipped - binary/long line ***') withColor:(Color darkRed)). |
15105 | 1788 |
]. |
1789 |
contentsMatches := false. |
|
1790 |
] do:[ |
|
18370 | 1791 |
bytesSearchedCount := bytesSearchedCount + sz. |
16186 | 1792 |
bigFile ifTrue:[ |
1793 |
Stream lineTooLongErrorSignal handle:[:ex | |
|
1794 |
showUnreadableFilesAndDirectoriesHolder value ifTrue:[ |
|
18675 | 1795 |
resultList add: (('*** ' , f pathName , ' skipped - too large ***') withColor:(Color darkRed)). |
15105 | 1796 |
]. |
16186 | 1797 |
contentsMatches := false. |
1798 |
] do:[ |
|
1799 |
contentsMatches := false. |
|
1800 |
(check == easyCheck |
|
1801 |
and:[ realFile size < (128*1024) ]) ifTrue:[ |
|
1802 |
check notNil ifTrue:[ |
|
1803 |
contentsMatches := realFile contentsAsString includesString: contentsString caseSensitive:ignCaseInContents not. |
|
1804 |
(contentsMatches and:[ checkNot notNil ]) ifTrue:[ |
|
1805 |
contentsMatches := (realFile contentsAsString includesString: notContentsString caseSensitive:ignCaseInNotContents not) not. |
|
1806 |
]. |
|
1807 |
] ifFalse:[ |
|
1808 |
checkNot notNil ifTrue:[ |
|
1809 |
contentsMatches := (realFile contentsAsString includesString: notContentsString caseSensitive:ignCaseInNotContents not) not. |
|
1810 |
]. |
|
1811 |
]. |
|
1812 |
] ifFalse:[ |
|
1813 |
contentsNotMatches := false. |
|
1814 |
realFile readingFileDo:[:stream | |
|
1815 |
[contentsMatches or:[contentsNotMatches or:[stream atEnd]]] whileFalse:[ |
|
1816 |
|line| |
|
1817 |
||
1818 |
line := stream nextLine. |
|
1819 |
check notNil ifTrue:[ |
|
1820 |
contentsMatches := check value:line |
|
1821 |
]. |
|
1822 |
checkNot notNil ifTrue:[ |
|
1823 |
contentsNotMatches := checkNot value:line |
|
1824 |
]. |
|
1825 |
] |
|
1826 |
]. |
|
15105 | 1827 |
]. |
12385 | 1828 |
]. |
1829 |
] ifFalse:[ |
|
16186 | 1830 |
lines := realFile contents ? #(). |
1831 |
check notNil ifTrue:[ |
|
1832 |
contentsMatches := lines contains:check |
|
12385 | 1833 |
]. |
16186 | 1834 |
(contentsMatches and:[ checkNot notNil ]) ifTrue:[ |
1835 |
contentsMatches := (lines contains:checkNot) not |
|
1836 |
] |
|
1837 |
] |
|
15105 | 1838 |
]. |
16186 | 1839 |
]. |
15105 | 1840 |
]. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1841 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1842 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1843 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1844 |
contentsMatches |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1845 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1846 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1847 |
]. |
11097 | 1848 |
doesFileMatch := self fileSizeWrapperFor:doesFileMatch. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1849 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1850 |
|
11473 | 1851 |
doesFileMatch := self modificationTimeWrapperFor:doesFileMatch. |
1852 |
||
10441 | 1853 |
namePatterns isNil ifTrue:[ |
1854 |
nameMatch := [:fn | true] |
|
1855 |
] ifFalse:[ |
|
1856 |
ignCaseInName ifTrue:[ |
|
1857 |
nameMatch := [:fn | namePatterns contains:[:aPattern | aPattern match:(fn asLowercase)]]. |
|
1858 |
] ifFalse:[ |
|
1859 |
nameMatch := [:fn | namePatterns contains:[:aPattern | aPattern match:fn]]. |
|
1860 |
]. |
|
1861 |
]. |
|
1862 |
||
1863 |
excludedNamePatterns isNil ifTrue:[ |
|
1864 |
nameExcludedMatch := [:fn | true] |
|
1865 |
] ifFalse:[ |
|
1866 |
ignoreCaseInExcludedName ifTrue:[ |
|
1867 |
nameExcludedMatch := [:fn | excludedNamePatterns contains:[:aPattern | aPattern match:(fn asLowercase)]]. |
|
1868 |
] ifFalse:[ |
|
1869 |
nameExcludedMatch := [:fn | excludedNamePatterns contains:[:aPattern | aPattern match:fn]]. |
|
1870 |
]. |
|
1871 |
]. |
|
1872 |
||
1873 |
"/ combine |
|
1874 |
namePatterns isNil ifTrue:[ |
|
1875 |
excludedNamePatterns isNil ifTrue:[ |
|
1876 |
realNameMatch := [:fn | true] |
|
1877 |
] ifFalse:[ |
|
1878 |
realNameMatch := [:fn | (nameExcludedMatch value:fn) not] |
|
1879 |
]. |
|
1880 |
] ifFalse:[ |
|
1881 |
excludedNamePatterns isNil ifTrue:[ |
|
1882 |
realNameMatch := nameMatch |
|
1883 |
] ifFalse:[ |
|
1884 |
realNameMatch := [:fn | (nameMatch value:fn) and:[ (nameExcludedMatch value:fn) not ]] |
|
1885 |
]. |
|
1886 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1887 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1888 |
(self canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1889 |
and:[self useLocate value |
16574 | 1890 |
and:[searchDirectories not |
1891 |
and:[theSingleDirectory notNil]]]) |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1892 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1893 |
[ |
16639 | 1894 |
|updateInfo cmd line f| |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1895 |
|
16639 | 1896 |
updateInfo := |
1897 |
[ |
|
1898 |
self |
|
1899 |
changeInformationTo:('%1 found' bindWith:resultList size) |
|
1900 |
toTab:false. |
|
1901 |
]. |
|
1902 |
||
1903 |
self window shown ifTrue:[ |
|
1904 |
updateInfo value. |
|
1905 |
]. |
|
1906 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1907 |
cmd := 'locate '. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1908 |
ignCaseInName ifTrue:[ |
16186 | 1909 |
"/ cmd := cmd , '--ignore-case ' |
1910 |
cmd := cmd , '-i ' |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1911 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1912 |
|
16186 | 1913 |
cmd := cmd , ((namePatterns |
1914 |
collect:[:nm | '"',nm,'"']) |
|
1915 |
asStringCollection asStringWith:Character space). |
|
16574 | 1916 |
inStream := PipeStream readingFrom:cmd inDirectory:theSingleDirectory. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1917 |
[inStream atEnd] whileFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1918 |
line := inStream nextLine. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1919 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1920 |
f := line asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1921 |
(doesFileMatch value:f) ifTrue:[ |
5859 | 1922 |
resultList add:line. |
16639 | 1923 |
updateInfo value. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1924 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1925 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1926 |
] ensure:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1927 |
inStream notNil ifTrue:[inStream close]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1928 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1929 |
^ self. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1930 |
]. |
12339 | 1931 |
|
3892 | 1932 |
bytesToCompareContentsOrNil notNil ifTrue:[ |
1933 |
contentsToCompare := bytesToCompareContentsOrNil |
|
1934 |
]. |
|
1935 |
||
12385 | 1936 |
filenameToCompareContentsOrNil notEmptyOrNil ifTrue:[ |
5727 | 1937 |
self searchOnlyInCache value ifTrue:[ |
5726 | 1938 |
cache notEmptyOrNil ifTrue:[ |
1939 |
cache keysAndValuesDo:[:fn :info | |
|
5768 | 1940 |
|filesSize filesMD5 idxInList| |
12339 | 1941 |
|
5726 | 1942 |
filesSize := info at:1. |
1943 |
filesSize isNil ifTrue:[ |
|
1944 |
filesSize := fn asFilename fileSize. |
|
1945 |
info at:1 put:filesSize. |
|
1946 |
]. |
|
5768 | 1947 |
(idxInList := fileSizesToSearchFor indexOf:filesSize) ~~ 0 ifTrue:[ |
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
6183
diff
changeset
|
1948 |
(setOfFilesToSearchFor includes:fn) ifFalse:[ |
5729 | 1949 |
fn asFilename exists ifFalse:[ |
1950 |
info at:1 put:nil. |
|
1951 |
info at:2 put:nil. |
|
1952 |
] ifTrue:[ |
|
1953 |
filesMD5 := info at:2. |
|
1954 |
filesMD5 isNil ifTrue:[ |
|
1955 |
filesMD5 := MD5Stream hashValueOfFile:fn asFilename. |
|
1956 |
info at:2 put:filesMD5. |
|
1957 |
]. |
|
5768 | 1958 |
filesMD5 = (fileMD5sToSearchFor at:idxInList) ifTrue:[ |
5859 | 1959 |
resultList add:fn. |
5728 | 1960 |
] |
5727 | 1961 |
] |
5726 | 1962 |
] |
1963 |
] |
|
1964 |
]. |
|
1965 |
]. |
|
1966 |
^ self. |
|
1967 |
]. |
|
1968 |
]. |
|
1969 |
||
18370 | 1970 |
filesSearchedCount := bytesSearchedCount := 0. |
15217 | 1971 |
|
16574 | 1972 |
aDirectoryOrCollectionOfDirectories do:[:eachDir | |
1973 |
self |
|
1974 |
doFindFileNamed:namePatterns |
|
1975 |
directories:searchDirectories |
|
1976 |
nameMatch:realNameMatch |
|
1977 |
contentsMatch:doesFileMatch |
|
1978 |
in:eachDir. |
|
1979 |
] |
|
17751 | 1980 |
|
10441 | 1981 |
"Created: / 03-08-2011 / 18:16:02 / cg" |
17751 | 1982 |
"Modified: / 12-11-2017 / 17:50:01 / cg" |
18675 | 1983 |
"Modified: / 13-03-2019 / 21:20:12 / Claus Gittinger" |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1984 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1985 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1986 |
doFindFileNamed:namePatterns directories:searchDirectories nameMatch:nameMatch contentsMatch:doesFileMatch in:aDirectory |
15217 | 1987 |
"the recursive walker. Searches for files matching namematch-block, |
1988 |
and contents matching doesFileMatch-block" |
|
1989 |
||
1990 |
|dir subDirs list directoryContents updateInfo| |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1991 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1992 |
dir := aDirectory asFilename. |
5844 | 1993 |
|
15217 | 1994 |
updateInfo := |
1995 |
[ |
|
1996 |
self |
|
1997 |
changeInformationTo:('%1 found - searching %2' |
|
1998 |
bindWith:resultList size |
|
18709 | 1999 |
with:(((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) |
2000 |
contractTo:80)) |
|
15217 | 2001 |
toTab:false. |
2002 |
]. |
|
2003 |
||
14748 | 2004 |
self window shown ifTrue:[ |
15217 | 2005 |
updateInfo value. |
14748 | 2006 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
2007 |
list := self resultList. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
2008 |
|
3892 | 2009 |
subDirs := OrderedCollection new. |
2010 |
||
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
2011 |
[ |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
2012 |
directoryContents := dir directoryContents. |
19399 | 2013 |
] on:OpenError do:[:ex| |
15660 | 2014 |
self showUnreadableFilesAndDirectoriesHolder value ifTrue:[ |
18675 | 2015 |
list add:((ex pathName , ' -> ' , ex description) withColor:Color darkRed). |
15660 | 2016 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
2017 |
"/ 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
|
2018 |
"/ bindWith:ex parameter printString |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
2019 |
"/ with:ex description) withCRs. |
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
2020 |
^ self |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
2021 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
2022 |
|
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
2023 |
directoryContents sort do:[:fn | |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
2024 |
|f isDirectory| |
3892 | 2025 |
|
2026 |
f := dir construct:fn. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
2027 |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
2028 |
isDirectory := f isDirectory. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
2029 |
isDirectory ifTrue:[ |
3892 | 2030 |
f isSymbolicLink ifFalse:[ |
2031 |
subDirs add:f |
|
2032 |
] |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
2033 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
2034 |
(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
|
2035 |
(nameMatch value:fn) ifTrue:[ |
15217 | 2036 |
filesSearchedCount := (filesSearchedCount ? 0) + 1. |
18370 | 2037 |
(isDirectory or:[ doesFileMatch value:f ]) ifTrue:[ |
15217 | 2038 |
updateInfo value. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
2039 |
list add:(f asString). |
3892 | 2040 |
] |
2041 |
] |
|
2042 |
] |
|
2043 |
]. |
|
2044 |
||
2045 |
self searchRecursively value ifTrue:[ |
|
2046 |
subDirs do:[:dir | |
|
2047 |
self |
|
2048 |
doFindFileNamed:namePatterns |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
2049 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
2050 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
2051 |
contentsMatch:doesFileMatch |
3892 | 2052 |
in:dir |
2053 |
]. |
|
2054 |
] |
|
10441 | 2055 |
|
15660 | 2056 |
"Modified: / 22-05-2015 / 11:42:17 / cg" |
18709 | 2057 |
"Modified: / 23-03-2019 / 12:27:35 / Claus Gittinger" |
11097 | 2058 |
! |
2059 |
||
2060 |
fileSizeWrapperFor:aFileMatchBlock |
|
17856 | 2061 |
"possibly wrap the search-match block into a file-size matcher block" |
11097 | 2062 |
|
2063 |
|fileSizeToCompare sizeMatch op compare| |
|
2064 |
||
2065 |
self enableFileSizeFilter value ifFalse:[ ^ aFileMatchBlock ]. |
|
2066 |
||
2067 |
fileSizeToCompare := self fileSizeHolder value. |
|
2068 |
op := self fileSizeOperatorHolder value withoutSeparators. |
|
2069 |
op = '~' ifTrue:[ |
|
2070 |
compare := [:sz | sz between:(fileSizeToCompare*0.9) and:(fileSizeToCompare*1.1) ]. |
|
2071 |
] ifFalse:[ |
|
2072 |
op := op asSymbol. |
|
2073 |
compare := [:sz | sz perform:op with:fileSizeToCompare ]. |
|
2074 |
]. |
|
2075 |
||
17855 | 2076 |
sizeMatch := [:f | compare value:(f fileSize ? 0) ]. |
11097 | 2077 |
|
2078 |
^ [:f | (sizeMatch value:f) and:[ aFileMatchBlock value:f ]] |
|
2079 |
||
2080 |
"Created: / 11-01-2012 / 23:17:02 / cg" |
|
11473 | 2081 |
! |
2082 |
||
2083 |
modificationTimeWrapperFor:aFileMatchBlock |
|
17856 | 2084 |
"possibly wrap the search-match block into a modification time matcher block" |
11473 | 2085 |
|
16810 | 2086 |
|timeToCompare timeMatch idx op compare| |
11473 | 2087 |
|
2088 |
self enableModificationTimeFilter value ifFalse:[ ^ aFileMatchBlock ]. |
|
2089 |
||
2090 |
timeToCompare := self modificationTimeHolder value. |
|
16810 | 2091 |
idx := self modificationTimeOperatorIndexHolder value. |
2092 |
op := self modificationTimeOperatorValueList at:idx. |
|
2093 |
op = #after ifTrue:[ |
|
11473 | 2094 |
compare := [:t | t > timeToCompare ]. |
2095 |
] ifFalse:[ |
|
16810 | 2096 |
op = #before ifTrue:[ |
2097 |
compare := [:t | t < timeToCompare ]. |
|
2098 |
] ifFalse:[ |
|
2099 |
op = #inDay ifTrue:[ |
|
2100 |
timeToCompare := timeToCompare asDate. |
|
2101 |
compare := [:t | t asDate = timeToCompare ]. |
|
2102 |
] ifFalse:[ |
|
2103 |
op = #inMonth ifTrue:[ |
|
2104 |
timeToCompare := timeToCompare asDate. |
|
2105 |
compare := [:t | t month = timeToCompare month |
|
2106 |
and:[t year = timeToCompare year] ]. |
|
2107 |
] ifFalse:[ |
|
2108 |
op = #inYear ifTrue:[ |
|
2109 |
timeToCompare := timeToCompare asDate. |
|
2110 |
compare := [:t | t year = timeToCompare year ]. |
|
2111 |
] ifFalse:[ |
|
2112 |
self halt. |
|
2113 |
]. |
|
2114 |
]. |
|
2115 |
]. |
|
2116 |
]. |
|
11473 | 2117 |
]. |
2118 |
||
2119 |
timeMatch := [:f | |
|
2120 |
|t| |
|
2121 |
||
2122 |
t := f modificationTime. |
|
2123 |
t notNil and:[ compare value:t ] |
|
2124 |
]. |
|
2125 |
||
2126 |
^ [:f | (timeMatch value:f) and:[ aFileMatchBlock value:f ]] |
|
2127 |
||
2128 |
"Created: / 28-03-2012 / 23:18:32 / cg" |
|
3892 | 2129 |
! ! |
2130 |
||
2131 |
!FindFileApplication methodsFor:'queries'! |
|
2132 |
||
7688 | 2133 |
getTabValueString |
2134 |
"the item shown in a tab (not language translated)" |
|
3892 | 2135 |
|
7691 | 2136 |
^ self fileName directory baseName |
7688 | 2137 |
|
2138 |
"Created: / 01-03-2007 / 21:39:54 / cg" |
|
3892 | 2139 |
! ! |
2140 |
||
2141 |
!FindFileApplication methodsFor:'startup & release'! |
|
2142 |
||
11101 | 2143 |
initialize |
17368 | 2144 |
<modifier: #super> "must be called if redefined" |
2145 |
||
11101 | 2146 |
super initialize. |
2147 |
||
2148 |
self enableStop value:false. |
|
2149 |
self enableSearch value:true. |
|
2150 |
||
2151 |
"Created: / 12-01-2012 / 01:38:29 / cg" |
|
17368 | 2152 |
"Modified: / 08-02-2017 / 00:27:53 / cg" |
11101 | 2153 |
! |
2154 |
||
5010 | 2155 |
item:anItem |
3892 | 2156 |
|
4797 | 2157 |
|file newPattern| |
3892 | 2158 |
|
5010 | 2159 |
super item:anItem. |
4797 | 2160 |
|
3892 | 2161 |
file := self fileName. |
19260 | 2162 |
file isNil ifTrue:[^ false]. |
2163 |
||
19013 | 2164 |
self searchDirectoryHolder value:(AbstractFileBrowser getDirectoryOf:file). |
4797 | 2165 |
|
3892 | 2166 |
file isDirectory ifTrue:[ |
4797 | 2167 |
newPattern := '*'. |
3892 | 2168 |
] ifFalse:[ |
12739 | 2169 |
anItem suffix isEmptyOrNil ifTrue:[ |
2170 |
newPattern := '*'. |
|
2171 |
] ifFalse:[ |
|
2172 |
newPattern := '*.', anItem suffix. |
|
2173 |
]. |
|
3892 | 2174 |
]. |
4797 | 2175 |
self namePatternHolder value:newPattern. |
3892 | 2176 |
^ true. |
11101 | 2177 |
|
2178 |
"Modified: / 12-01-2012 / 01:38:14 / cg" |
|
3892 | 2179 |
! |
2180 |
||
2181 |
postOpenWith:aBuilder |
|
2182 |
self masterApplication isNil ifTrue:[ |
|
2183 |
self masterApplication:nil. |
|
2184 |
]. |
|
2185 |
findFileView := aBuilder window. |
|
2186 |
self windowGroup addPreEventHook:self. |
|
6633 | 2187 |
super postOpenWith:aBuilder. |
11101 | 2188 |
|
2189 |
"Modified (format): / 12-01-2012 / 01:40:44 / cg" |
|
3892 | 2190 |
! |
2191 |
||
2192 |
release |
|
2193 |
self stopSearchTask. |
|
6107 | 2194 |
contentsInfoCache := nil. |
14064 | 2195 |
super release |
3892 | 2196 |
! ! |
2197 |
||
2198 |
!FindFileApplication class methodsFor:'documentation'! |
|
2199 |
||
2200 |
version |
|
16186 | 2201 |
^ '$Header$' |
9036
9242245f6689
no need for #asText to emphasize a string
Claus Gittinger <cg@exept.de>
parents:
8613
diff
changeset
|
2202 |
! |
9242245f6689
no need for #asText to emphasize a string
Claus Gittinger <cg@exept.de>
parents:
8613
diff
changeset
|
2203 |
|
9242245f6689
no need for #asText to emphasize a string
Claus Gittinger <cg@exept.de>
parents:
8613
diff
changeset
|
2204 |
version_CVS |
16186 | 2205 |
^ '$Header$' |
3892 | 2206 |
! ! |
12339 | 2207 |