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