Anonymous user
Walk a directory/Recursively: Difference between revisions
→{{header|Forth}}
(Added Kotlin) |
|||
Line 826:
=={{header|Forth}}==
{{works with|gforth|0.
require unix/filestat.fs
▲<lang forth>defer ls-filter
require unix/libc.fs
: $append ( from len to -- ) 2DUP >R >R COUNT + SWAP MOVE R> R@ C@ + R> C! ;
: dots? ( name len -- ? )▼
dup 1 = if drop c@ [char] . =▼
defer ls-filter
: ls-r ( dir len -- )▼
open-dir if drop exit then ( dirid)▼
file-stat buffer: statbuf
: isdir ( addr u -- flag )
statbuf lstat ?ior statbuf st_mode w@ S_IFMT and S_IFDIR = ;
▲: (ls-r) ( dir len -- )
pad c@ >r pad $append s" /" pad $append
▲ pad count open-dir if drop r> pad c! exit then ( dirid)
begin
dup pad count + 256 rot read-dir throw
while
pad count + over dots? 0= if \ ignore
dup pad
isdir if
pad count + swap recurse
else drop then
else drop then
repeat
drop
close-dir throw
;
:
dup 3 < if 2drop false exit then
+ 1- dup c@ 32 or
Line 855 ⟶ 869:
1- dup c@ [char] . <> if drop false exit then
drop true ;
' c-
: all-files ( str len -- ? ) 2drop true ;
' all-files is ls-filter
s" ." ls-r
</lang>
=={{header|Gambas}}==
|