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