Walk a directory/Recursively: Difference between revisions

No edit summary
Line 1,365:
 
.say for find(dir => '.').grep(/foo/);</lang>
 
=={{header|Phix}}==
There is a builtin routine for this, walk_dir() - if interested you can find the full implementation in builtins\file.e (an autoinclude).
<lang Phix>function find_pfile(string pathname, sequence dirent)
if match("pfile.e",dirent[D_NAME]) then
-- return pathname&dirent[D_NAME] -- to terminate scan
?pathname&"\\"&dirent[D_NAME]
end if
return 0
end function
 
?walk_dir("C:\\Program Files (x86)\\Phix",routine_id("find_pfile"),1)</lang>
Passing 1 as the third parameter makes it scan recursively.
{{out}}
<pre>
"C:\\Program Files (x86)\\Phix\\.hg\\store\\data\\builtins\\pfile.e.i"
"C:\\Program Files (x86)\\Phix\\builtins\\pfile.e"
0
</pre>
<small>[the final 0 is from the walk_dir() call, whereas both paths are printed from inside find_pfile()]</small>
 
=={{header|PHP}}==
7,818

edits