中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
HarmonyOS 使用 zlib.decompressFile 会报错 17700101
微信扫码分享
// 参考demo如下可以实现成功解压 function zlibDecompress() { getContext().resourceManager.getRawFileContent('miniprogram2.zip', (_err, value) => { let myBuffer:ArrayBufferLike = value.buffer let context = getContext(); //沙箱路径 let filePath = context.filesDir + "/miniprogram2.zip"; console.log("testTag-filePath:" + filePath); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); let writeLen = fs.writeSync(file.fd, myBuffer); console.info("testTag-write data to file succeed and size is:" + writeLen); fs.closeSync(file); let inFile = getContext().filesDir + "/miniprogram2.zip"; let outFileDir = getContext().filesDir; let options: zlib.Options = { level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION }; try { zlib.decompressFile(inFile, outFileDir, options, (errData: BusinessError) => { if (errData !== null) { console.error(`errData is errCode:${errData.code} message:${errData.message}`); } }) } catch(errData) { let code = (errData as BusinessError).code; let message = (errData as BusinessError).message; console.error(`errData is errCode:${code} message:${message}`); } }) }