Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
This project is maintained by Kray-G
The Directory
object will be used to traverse a directory/folder tree.
There are 2 methods below.
Methods | Outline |
---|---|
walk(dir, callback) |
Even when finding a sub directory, it does NOT go into that sub directoty. |
recursiveWalk(dir, callback) |
When finding a sub directory, it goes into that sub directoty. |
change(dir, callback) |
Do something callback in dir directory. |
Here is generally how to display files stored under some folder.
Directory.walk("src") { &(name)
System.println(name);
};
Here is how to traverse folders recursively and to display found files all.
Directory.recursiveWalk("src") { &(name)
System.println(name);
};
Here is how to work in a secified directory.
Directory.change("src") {
// Work in "src" directory.
System.println(name);
};
walk
var result = [];
Directory.walk("build/template/theme/standard") { &(name)
result.push(name);
};
result.sort().each { System.println(_1); };
build/template/theme/standard/installer.ico
build/template/theme/standard/installer.png
build/template/theme/standard/uninstaller.ico
build/template/theme/standard/uninstaller.png
build/template/theme/standard/wizard-uninst.bmp
build/template/theme/standard/wizard.bmp
walk
var result = [];
Directory.walk("build/template/theme") { &(name)
result.push(name);
};
result.sort().each { System.println(_1); };
build/template/theme/standard
recursiveWalk
var result = [];
Directory.recursiveWalk("build/template/theme") { &(name)
result.push(name);
};
result.sort().each { System.println(_1); };
build/template/theme/standard
build/template/theme/standard/installer.ico
build/template/theme/standard/installer.png
build/template/theme/standard/uninstaller.ico
build/template/theme/standard/uninstaller.png
build/template/theme/standard/wizard-uninst.bmp
build/template/theme/standard/wizard.bmp
change
var path = $pwd;
var dirname = path.filename();
Directory.change("..") {
var d = $pwd / dirname;
System.println(d == path);
};
1