Class Filesystem.Traversion
- Description
Iterator object that traverses a directory tree and returns files as values and paths as indices. Example that uses the iterator to create a really simple sort of make:
- Example
object i=Filesystem.Traversion("."); foreach(i; string dir; string file) { if(!has_suffix(file, ".c")) continue; file = dir+file; string ofile = file; ofile[-1]='o'; object s=file_stat(ofile); if(s && i->stat()->mtime<s->mtime) continue; // compile file }
- Method create
Filesystem.Traversion Filesystem.Traversion(string path, void|bool symlink, void|bool ignore_errors, void|function(array:array) sort_fun)
- Parameter path
The root path from which to traverse.
- Parameter symlink
Don't traverse symlink directories.
- Parameter ignore_errors
Ignore directories that can not be accessed.
- Parameter sort_fun
Sort function to be applied to directory entries before traversing. Can also be a filter function.