T-M2-01 存储/文件:KvStore(preferences 持久化 urlpath/upurlpath)、FileSystem(fileIo 建删读写/列目录/拷贝内置 rawfile)
T-M2-02 网络/下载:HttpClient(GET 禁缓存,契约 §4.3)、Downloader(http 流式写盘+进度,原生异步不阻塞 UI)
T-M2-03 解压:Unzipper(zlib.decompressFile,原生异步)。偏差:下载/解压用原生异步 API 即满足"UI 不阻塞",
独立 TaskScheduler(TaskPool) 推迟到 M5 真有 CPU 密集任务(MD5)时再加,避免投机性死代码。
T-M2-04 权限/上传:PermissionGuard(用时申请,沙箱文件免存储权限)、LocalUploadServer(骨架,本机端口服务 M3 落地)
devecocli build 通过。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
22 lines
886 B
Plaintext
22 lines
886 B
Plaintext
/**
|
|
* 解压器(框架 §8.3 / §9.1 / 附录 A.4)。封装 @kit.BasicServicesKit zlib.decompressFile。
|
|
*
|
|
* decompressFile 为**原生异步**——解压在系统侧执行、不阻塞 UI 线程,满足"解压不卡 UI"。
|
|
* 契约 §5.4:远程 zip 顶层即含 gamehall/...,解压到 <解压根>/ 即可。
|
|
*/
|
|
import { zlib } from '@kit.BasicServicesKit';
|
|
import { FileSystem } from '../fs/FileSystem';
|
|
import { Logger } from 'common';
|
|
|
|
export class Unzipper {
|
|
private static readonly log: Logger = Logger.tag('Unzipper');
|
|
|
|
/** 解压 zipPath 到 destDir(自动建目标目录)。失败抛出。 */
|
|
static async unzip(zipPath: string, destDir: string): Promise<void> {
|
|
FileSystem.ensureDir(destDir);
|
|
const options: zlib.Options = {};
|
|
await zlib.decompressFile(zipPath, destDir, options);
|
|
Unzipper.log.i(`unzip ${zipPath} -> ${destDir}`);
|
|
}
|
|
}
|