bug fix in xrange() that would cause it to yield bogus values
[vox.git] / examples / walk.vx
blobb052aada894db4a9757a6fc021e92e4a435cb86c
2 function walk(dir, cb)
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     }
24 walk(os.dirname(system.argv[0]), function(dir, path, fullpath, isdir)
26     if(!isdir)
27     {
28         println(path)
29         io.stdout.flush()
30     }