repo.or.cz
/
vox.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
bug fix in xrange() that would cause it to yield bogus values
[vox.git]
/
examples
/
walk.vx
blob
b052aada894db4a9757a6fc021e92e4a435cb86c
1
2
function walk(dir, cb)
3
{
4
try
5
{
6
local files = os.listdir(dir)
7
foreach(path in files)
8
{
9
local fullpath = path
10
local isd = os.isdir(fullpath)
11
cb((isd ? fullpath : dir), path, fullpath, isd)
12
if(isd)
13
{
14
walk(fullpath, cb)
15
}
16
}
17
}
18
catch(err)
19
{
20
io.stderr.write("walk(%s): error: %s\n".fmt(dir, err))
21
}
22
}
23
24
walk(os.dirname(system.argv[0]), function(dir, path, fullpath, isdir)
25
{
26
if(!isdir)
27
{
28
println(path)
29
io.stdout.flush()
30
}
31
})