Created
September 16, 2010 14:42
-
-
Save vilmibm/582532 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
sys = require('sys'); | |
function walk(path, callback) { | |
var recur_or_cb = function( abspath ) { | |
return function(err, stats) { | |
if ( stats.isDirectory() ) | |
walk(abspath, callback); | |
else | |
callback(err, abspath); | |
}; | |
}; | |
fs.readdir(path, function(err, files) { | |
files.forEach(function(f) { | |
abspath = path + '/' + f; | |
fs.stat(abspath, recur_or_cb(abspath)); | |
}); | |
}); | |
} | |
walk('/home/nate/Music', function(err, path) { sys.print(path+"\n") }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm banking on the "n /'s are okay in Unix". An os.join parrallel would be helpful.