array :dir-list ( string $DIRECTORY , string $PATTERN , string $FLAGS )
array :dir-list ( string $DIRECTORY , string $PATTERN )
array :dir-list ( string $DIRECTORY )
Lists entries in DIRECTORY, according to PATTERN. Inside PATTERN, *
and ?
wildcards are recognized. If omitted altogether, the pattern defaults to *
(all entries).
FLAGS should be a string. If a format character is present within the string, it enables the corresponding flag.
Character | Description |
---|---|
d | List subdirectories, too. By default, only files are listed. |
h | List hidden files, too. By default, only visible files are listed. |
r | Recurse subdirectories. CAUTION: only subdirs matching the pattern will be visited. |
s | Sort entries ASCII-wise. By default, entries are returned in filesystem order. |
w | Do not list read-only files. By default, both writeable and read-only files are listed. |
/ | Append a / (Linux) or \ (Windows) to the end of each subdirectory listed. Obviously, usable only with d . |
# :dir-list example - a utility to delete all files in a directory !if :not :param-num :writeln s'Usage: cleandir.yuk <path>' :exit !fi :set &list :dir-list :param-str i0 :set &idx i0 !while :lt $idx :param-num !if :file-unlink :param-str $idx :writeln s'Removed: ' :param-str $idx !else :writeln s'Error: ' :param-str $idx !fi :add &idx i1 !done
wikipage modified on 2014/0611/1326