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