Jump to content

Walk a directory/Recursively: Difference between revisions

→‎{{header|Tcl}}: ++ smalltalk
(→‎{{header|Tcl}}: ++ smalltalk)
Line 454:
for(f <- root.andTree; if f.getName.endsWith(".mp3")) Console.println(f)
}
 
=={{header|Smalltalk}}==
{{works with|GNU Smalltalk}}
<lang smalltalk>Directory extend [
wholeContent: aPattern do: twoBlock [
self wholeContent: aPattern withLevel: 0 do: twoBlock.
]
wholeContent: aPattern withLevel: l do: twoBlock [
|cont|
cont := (self contents) asOrderedCollection.
cont remove: '.'; remove: '..'.
cont
do: [ :fn |
((File name: fn) isDirectory)
ifTrue: [
twoBlock value: (fn, '/') value: l.
(Directory name: fn) wholeContent: aPattern withLevel: (l+1) do: twoBlock
]
ifFalse: [
( fn =~ aPattern )
ifMatched: [ :m |
twoBlock value: fn value: l
]
]
]
]
].</lang>
 
<lang smalltalk>|d|
d := Directory name: '.'.
d wholeContent: '.st$' do: [ :f :l |
0 to: l do: [ :i | (Character tab) display ].
f displayNl
].</lang>
 
=={{header|Tcl}}==
Line 471 ⟶ 505:
# replace directory with something appropriate
walkin /home/user
 
 
=={{header|Visual Basic .NET}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.