Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / walkdir / test / comparison / find.js
1 var spawn = require('child_process').spawn;
2
3 var find = spawn('find',[process.argv[2]||'./']);
4
5 var fs = require('fs');
6
7 var buf = '',count = 0;
8
9 handleBuf = function(data){
10
11         buf += data;
12
13         if(buf.length >= 1024) {
14                 var lines = buf.split("\n");
15                 buf = lines.pop();//last line my not be complete
16                 count += lines.length;
17                 process.stdout.write(lines.join("\n")+"\n");
18         }
19 };
20
21 find.stdout.on('data',function(data){
22         //buf += data.toString();
23         handleBuf(data)
24         //process.stdout.write(data.toString());
25 });
26
27 find.on('end',function(){
28         handleBuf("\n");
29         console.log('found '+count+' files');
30         console.log('ended');
31 });
32
33 find.stdin.end();