Walk a directory/Non-recursively: Difference between revisions

m
(Added Odin variant)
m (→‎{{header|Wren}}: Minor tidy)
 
(4 intermediate revisions by 4 users not shown)
Line 750:
 
=={{header|Elena}}==
ELENA 46.0x:
<syntaxhighlight lang="elena">import system'io;
import system'routines;
Line 759:
var dir := Directory.assign("c:\MyDir");
dir.getFiles("a.*").forEach:(printingLn);
}</syntaxhighlight>
 
Line 885:
graphicalSieve.frink
...
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
 
void local fn EnumerateDirectoryAtURL( dirURL as CFURLRef )
NSDirectoryEnumerationOptions options = NSDirectoryEnumerationSkipsPackageDescendants + ¬
NSDirectoryEnumerationSkipsHiddenFiles + ¬
NSDirectoryEnumerationSkipsSubdirectoryDescendants
}
DirectoryEnumeratorRef enumerator = fn FileManagerEnumeratorAtURL( dirURL, NULL, options, NULL, NULL )
CFURLRef url = fn EnumeratorNextObject( enumerator )
while ( url )
if ( fn StringIsEqual( fn URLPathExtension( url ), @"fb" ) )
NSLog(@"%@",fn URLLastPathComponent( url ))
end if
url = fn EnumeratorNextObject( enumerator )
wend
end fn
 
fn EnumerateDirectoryAtURL( fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask ) )
 
HandleEvents
</syntaxhighlight>
 
{{out}}
<pre>
ListFormatter.fb
ObjectProperty1.fb
Archimedean Spiral with Bezier Curve.fb
FB3D.fb
lenArray.fb
Rosettacode Random Noise v04.fb
AssociatedObject.fb
</pre>
 
Line 1,401 ⟶ 1,436:
main :: proc() {
matches, _err := filepath.glob("*.odin")
for match in matches {do fmt.println(match)
fmt.println(match)
}
}</syntaxhighlight>
 
Line 1,781 ⟶ 1,814:
Finished
 
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
The very first instruction of this program <code>VARS</code> returns the list of all current files and subdirectories. The rest of the code retains the names that comply with the pattern given in input, and which are not directories. To do so, the program attempts to recall the contents of each object on the stack through <code>RCL</code>: if an error occurs, the object is then a directory and shall not be processed further.
≪ VARS → filter list
≪ { } 1 list SIZE '''FOR''' j
list j GET
'''IFERR''' DUP RCL '''THEN''' DROP2
'''ELSE'''
DROP →STR 2 OVER SIZE 1 - SUB
'''IF''' DUP filter POS '''THEN''' + ELSE DROP '''END'''
'''END'''
'''NEXT'''
≫ ≫
'WKDIR' STO
 
"T" WKDIR
{{out}}
<pre>
1: { "T" "TESTPGM" "FACTN" }
</pre>
 
Line 2,053 ⟶ 2,107:
=={{header|Wren}}==
{{libheader|Wren-pattern}}
<syntaxhighlight lang="ecmascriptwren">import "io" for Directory
import "./pattern" for Pattern
 
var walk = Fn.new { |dir, pattern|
9,482

edits