[AAuto]采用广度优先算法遍历目录

原创
2012/04/10 22:02
import console;import fsys;class spider{
ctor(){this.queue = {}
};
searchDir = function(dir){
..fsys.enum( dir, "*.*",function(dir,file,fullpath,findData){
if(file){
           if( this.fileProc ) this.fileProc(fullpath)
}else{
..table.push( this.queue,fullpath );
}
},false );
};
search = function(dir){
while(dir){if( this.dirProc ) this.dirProc(dir)this.searchDir(dir);
dir = ..table.remove(this.queue);
}
};
}var s = spider();
s.dirProc = function(dir){console.log("发现目录",dir)
}
s.fileProc = function(dir){console.log("发现文件",dir)
}
s.search("/")
(0)

相关推荐