"use strict";const fs=require("fs"),path=require("path"),FILE_COUNT_BEGIN=18,FILF_INFO_BEGIN=22;class WxvpkgReader{constructor(t){this.fileMap={},this.dirMap={},this.cache={},this._close=!0,this.readSync=(t,e)=>{this._close&&(this._close=!1,this.fd=fs.openSync(this._path,"r"));const i=Buffer.alloc(e);return fs.readSync(this.fd,i,0,e,t),i},this._path=t,this._stat=fs.statSync(t);const e=this.readSync(18,4).readInt32BE(0);this.fileMap=this.getFileMap(e)}cacheDirName(t){this.dirMap[t]||(this.dirMap[t]=!0,this.cacheDirName(path.dirname(t)))}getFileMapByJSON(){let t;try{const e=this._path.replace(".wxvpkg",".wx.fileinfo");console.log(e),t=JSON.parse(fs.readFileSync(e,"utf-8"));for(const e in t){const i=t[e];this.cacheDirName(path.dirname(i.name))}}catch(t){}return t}getFileMap(t){let e=this.getFileMapByJSON();if(!e){e={};let i=22;for(let s=0;s{}),this.fd=void 0),this._close=!0}}module.exports=WxvpkgReader;