[AAuto]采用广度优先算法遍历目录
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)