Skip to content

Instantly share code, notes, and snippets.

@vishakvkt
Last active August 29, 2015 14:08
Show Gist options
  • Save vishakvkt/8e359265d1641197b61f to your computer and use it in GitHub Desktop.
Save vishakvkt/8e359265d1641197b61f to your computer and use it in GitHub Desktop.
var Future = require('fibers/future');
var fs_f = Future.wrap(require('fs'));
if(process.argv.length < 3) {
console.log("format filestat <path>");
process.exit();
}
function processFileStats(stat) {
console.log(stat);
}
var path = process.argv[2];
Future.task(function() {
var directoryContents = fs_f.readdirFuture(path).wait();
var fileStats = [];
for(var i =0; i < directoryContents.length; i++) {
var fileStat = fs_f.statFuture(path + "\\" + directoryContents[i]).wait();
fileStats.push(fileStat);
}
for(var j = 0; j < fileStats.length; j++) {
processFileStats(fileStats[j]);
}
}).detach();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment