Walk a directory/Recursively: Difference between revisions
Content deleted Content added
Omiting MUMPS |
+Icon+Unicon |
||
Line 407: | Line 407: | ||
This will descend down the directory/ies in the variable <tt>"directory"</tt> (which can be an array) returning an array of strings with the names of the files matching "*.txt" and placing the total number of matches into the variable <tt>"cc"</tt> |
This will descend down the directory/ies in the variable <tt>"directory"</tt> (which can be an array) returning an array of strings with the names of the files matching "*.txt" and placing the total number of matches into the variable <tt>"cc"</tt> |
||
== Icon and Unicon == |
|||
==={{header|Icon}}=== |
|||
Icon doesn't support 'stat' or 'open' of a directory; however, information can be obtained by use of the system function to access command line. |
|||
==={{header|Unicon}}=== |
|||
<lang Unicon>procedure main() |
|||
every write(!getdirs(".")) # writes out all directories from the current directory down |
|||
end |
|||
procedure getdirs(s) #: return a list of directories beneath the directory 's' |
|||
local D,d,f |
|||
if ( stat(s).mode ? ="d" ) & ( d := open(s) ) then { |
|||
D := [s] |
|||
while f := read(d) do |
|||
if not ( ".." ? =f ) then # skip . and .. |
|||
D |||:= getdirs(s || "/" ||f) |
|||
close(d) |
|||
return D |
|||
} |
|||
end</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |