const fs=require("fs"),util=require("util"),path=require("path");let pfs={permit:(r,e=fs.constants.R_OK)=>new Promise(t=>{fs.access(r,e,(r,e)=>{t(r?0:1)})})};var funArr=["stat","lstat","fstat","copyFile","readdir","mkdir","rmdir","readFile","writeFile","appendFile","unlink","rename","chown"];funArr.forEach(r=>{fs[r]?pfs[r]=util.promisify(fs[r]):console.warn("函数不存在",r)}),pfs.remove=(async r=>{let e;try{e=await pfs.stat(r)}catch(r){return}if(e)if(e.isDirectory()){let e=await pfs.readdir(r);await Promise.all(e.map(e=>{let t=path.normalize(r+"/"+e);return pfs.remove(t)})),await pfs.rmdir(r)}else await pfs.unlink(r)}),module.exports=pfs;