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