mirror() { describe(path) { result = std.mirror.ls(path); for ( i = 0 ; i < sizeof(result) ; i++ ) { case ( result[i] ) of ( std.mirror.ls_var ) std.echo("var"); of ( std.mirror.ls_method ) std.echo("method"); of ( std.mirror.ls_module ) std.echo("module"); of ( std.mirror.ls_domain ) std.echo("domain"); of ( std.mirror.ls_agent ) std.echo("agent"); of ( std.mirror.ls_type ) std.echo("type"); std.echo("[", string(i), "] ", result[i++ + 1]); } } } fs.interface() { convert(path) { p = std.ss.dup(path); for ( i = 0 ; i < sizeof(p) ; i++ ) if ( p[i] == '.' ) p[i] = '/'; return p; } req(req) { query = "/" + convert( req ); if ( !posix.io.exists( query ) ) return ""; if ( posix.io.directory( query ) ) { dir = posix.io.opendir(query); count = 0; while ( posix.io.readdir(dir) ) count++; count = count - 2; posix.io.rewinddir(dir); i = 0; reflect = new [count * 2]; while ( file = posix.io.readdir(dir) ) { if ( file == "." || file == ".." ) continue; reflect[i++] = std.mirror.ls_module; reflect[i++] = file; } posix.io.closedir(dir); return reflect; } reflect = new [2]; reflect[0] = std.mirror.ls_module; reflect[1] = query; return reflect; } } fs(...) domain { if ( arg(0) == std.dom.mask_ls ) return fs.interface.req(arg(1)); } main() agent { new std.mirror(); new std.dom(); mirror.describe( "fs.etc" ); } # vim:syntax=edge