toosweettobereal

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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