Top index Wirbel home

fs::findfiles

findfiles(string d) - recursively find all files in a directory
findfiles(string d, function(tuple(string, string), boolean) filter) - find files matching a filter
findfiles(string d, string pattern) - find files matching a pattern

findfiles(string d) scans the directory d and all its subdirectories for files. Returns the relative pathnames of all those files. The result list does not include . and ..

findfiles(string d, function(tuple(string, string), boolean) filter) behaves like findfiles(string), but only include those entries that match the filter function filter. The function takes two arguments: the complete pathame and the filename of the entry. It must return true if that file should be included in the list and false otherwise.

findfiles(string d, string pattern) is a convenciance version of findfiles(d, filter) that find only those files whose name (not pathname) matches the shell wildcard pattern pattern

Examples

Find all symbolic links in /etc and below:

findfiles("/etc", lambda path, file: is_symlink(path)).len()
Find files in current directoy with a name of length 4:
findfiles(".", lambda path, file: file.len() == 4)

Find all Wirbel source files in /home:

findfiles("/home", "*.w")