Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / walkdir / test / comparison / fstream.js
diff --git a/legacy-libs/walkdir/test/comparison/fstream.js b/legacy-libs/walkdir/test/comparison/fstream.js
new file mode 100644 (file)
index 0000000..1451b4c
--- /dev/null
@@ -0,0 +1,24 @@
+var fstream = require('fstream');
+
+var pipe = fstream.Reader(process.argv[2]||"../");
+
+var count = 0,errorHandler;
+
+pipe.on('entry',function fn(entry){
+  if(entry.type == "Directory"){
+       entry.on('entry',fn);
+  } else if(entry.type == "File") {
+       count++;
+  }
+  entry.on('error',errorHandler);
+});
+
+pipe.on('error',(errorHandler = function(error){
+       console.log('error event ',error);
+}));
+
+pipe.on('end',function(){
+       console.log('end! '+count);
+});
+
+//this is pretty slow