export declare type APFilePath = string; export declare type UsrFilePath = string; export declare type TempFilePath = string; export interface IFileInfo { filePath: APFilePath; size: number; createTime: number; } export interface IFile { [key: string]: any; } export interface IWriteFileOptions { encoding?: string | null; } export interface IReadFileOptions { encoding?: string | null; } export declare enum EFileSystemPathType { AP = 'ap', Usr = 'usr', Temp = 'temp', } export interface IFileSystem { /** * 判断文件/目录是否存在 * @param filePath 文件虚拟路径 */ access(filePath: APFilePath): Promise; /** * 在文件结尾追加内容 * @param filePath 文件虚拟路径 * @param data 追加内容 * @param options 写入选项 */ appendFile(filePath: APFilePath, data: any, options?: IWriteFileOptions): Promise; /** * 保存临时文件到本地 * * Note: * - 此接口会移动临时文件,因此调用成功后,tempFilePath 将不可用 * - filePath 如果不传,默认存储在小程序缓存目录 * @param filePath 文件虚拟路径 */ saveFile(filePath: APFilePath | TempFilePath, pathType: EFileSystemPathType): Promise; /** * 获取该小程序下已保存的 `本地缓存文件` 列表 */ getSavedFileList(): Promise; /** * 删除该小程序下已保存的 `本地缓存文件` * @param filePath 文件虚拟路径 */ removeSavedFile( filePath: APFilePath | TempFilePath | UsrFilePath, pathType: EFileSystemPathType ): Promise; /** * 复制文件(支持复制 `临时文件` 、`缓存文件` 到沙箱文件) * @param srcPath 起始虚拟路径 * @param destPath 目标虚拟路径 */ copyFile(srcPath: APFilePath, destPath: APFilePath): Promise; /** * 获取该小程序下的 `本地临时文件` 或 `本地缓存文件` 信息 * @param filePath */ getFileInfo( filePath: APFilePath | TempFilePath | UsrFilePath, pathType: EFileSystemPathType ): Promise>; /** * 创建目录 * @param dirPath 目录虚拟路径 * @param recursive 是否递归创建 */ mkdir(dirPath: APFilePath, recursive: boolean): Promise; /** * 读取本地文件内容 * @param filePath 文件虚拟路径 * @param options 读取选项 */ readFile(filePath: APFilePath, options: IReadFileOptions): Promise; /** * 读取目录内文件列表 * @param dirPath 目录虚拟路径 */ readdir(dirPath: APFilePath): Promise; /** * 重命名文件,可以把文件从 `oldPath` 移动到 `newPath` * @param oldPath 文件虚拟路径 * @param newPath 目标虚拟路径 */ rename(oldPath: APFilePath, newPath: APFilePath): Promise; /** * 删除目录 * @param dirPath 目录虚拟路径 * @param recursive 是否递归删除 */ rmdir(dirPath: APFilePath, recursive: boolean): Promise; /** * 获取文件 Stats 对象 * @param filePath 文件虚拟路径 */ stat(filePath: APFilePath): Promise; /** * 删除文件 * @param filePath 文件虚拟路径 */ unlink(filePath: APFilePath): Promise; /** * 解压文件 * * Note:如果解压目录中存在 `../` 或者软链接,则解压失败 * @param zipFilePath 压缩文件虚拟路径 * @param targetPath 目标虚拟路径 */ unzip(zipFilePath: APFilePath, targetPath: APFilePath): Promise; /** * 写文件 * @param filePath 文件虚拟路径 * @param data 写入内容 * @param options 写入选项 */ writeFile(filePath: string, data: any, options?: IWriteFileOptions): Promise; } //# sourceMappingURL=fs.d.ts.map