枚举文件的两种办法
By
admin
at 2017-12-10 • 0人收藏 • 1639人看过
import console; import fsys console.open(); var sss = "sleep"; var 结果={} var t = time.tick() fsys.enum( "~/lib/", "*.aardio", function(dir,filename,fullpath,findData){ if(filename){ var str = string.load(fullpath) if(string.indexOf(str,sss)){ table.push(结果,fullpath) } } } ,/*如果此参数为false则忽略子目录*/ ); console.print(time.tick()-t) console.varDump(结果) execute("pause")
多线程方式:
import console; import fsys var fileTab = {} fsys.enum( "~/lib", "*.aardio", function(dir,filename,fullpath,findData){ if(filename){ // io.print("发现文件:"+filename,"完整路径:"+fullpath) table.push(fileTab,fullpath) } } ,/*如果此参数为false则忽略子目录*/ ); thread.set("标志键", "fsys") import thread.works var works = thread.works( 20, function( args ) { import console if(string.indexOf(string.load(args),thread.get("标志键"))) console.log(args) } ); for(i=1;#fileTab;1){ works.push(fileTab[i]) } works.wait() console.log("ok") console.pause(true);
1 个回复 | 最后更新于 2018-11-09
登录后方可回帖
如果想要一次枚举几种后缀, 那么只需要输入是个字符表即可.