Walk a directory/Recursively: Difference between revisions

Content added Content deleted
m (→‎{{header|Smalltalk}}: sorted instead of ordered)
m (→‎{{header|Smalltalk}}: several bug fixes that prevented the full deep exploration)
Line 466: Line 466:
cont remove: '.'; remove: '..'.
cont remove: '.'; remove: '..'.
cont
cont
do: [ :fn |
do: [ :n | |fn ps|
ps := (Directory pathSeparator) asString.
fn := (self name), ps, n.
((File name: fn) isDirectory)
((File name: fn) isDirectory)
ifTrue: [
ifTrue: [
twoBlock value: (fn, '/') value: l.
twoBlock value: (n, ps) value: l.
(Directory name: fn) wholeContent: aPattern withLevel: (l+1) do: twoBlock
(Directory name: fn) wholeContent: aPattern withLevel: (l+1) do: twoBlock.
]
]
ifFalse: [
ifFalse: [
( fn =~ aPattern )
( n =~ aPattern )
ifMatched: [ :m |
ifMatched: [ :m |
twoBlock value: fn value: l
twoBlock value: n value: l
]
]
]
]
Line 484: Line 486:
<lang smalltalk>|d|
<lang smalltalk>|d|
d := Directory name: '.'.
d := Directory name: '.'.
d wholeContent: '.st$' do: [ :f :l |
d wholeContent: '\.st$' do: [ :f :l |
0 to: l do: [ :i | (Character tab) display ].
0 to: l do: [ :i | (Character tab) display ].
f displayNl
f displayNl