interface StorageProvider { readJSON<T>(filePath: string): Promise<T | null>; writeJSON(filePath: string, data: any): Promise<void>; readText(filePath: string): Promise<string | null>; writeText(filePath: string, content: string): Promise<void>; appendText(filePath: string, content: string): Promise<void>; readBuffer(filePath: string): Promise<Buffer<ArrayBufferLike> | null>; writeBuffer(filePath: string, data: Buffer): Promise<void>; readDir(dirPath: string): Promise<string[]>; exists(filePath: string): Promise<boolean>; mkdir(dirPath: string): Promise<void>; remove(filePath: string): Promise<void>; removeDir(dirPath: string): Promise<void>; stat(filePath: string): Promise<Stats | null>; copy(src: string, dest: string): Promise<void>; readDirWithTypes(dirPath: string): Promise<Dirent<string>[]>;} 方法
readJSON
readJSON<T>(filePath: string): Promise<T | null>
writeJSON
writeJSON(filePath: string, data: any): Promise<void> 参数
- filePath: string
- data: any
返回 Promise<void>
readText
readText(filePath: string): Promise<string | null> 返回 Promise<string | null>
writeText
writeText(filePath: string, content: string): Promise<void> 参数
- filePath: string
- content: string
返回 Promise<void>
appendText
appendText(filePath: string, content: string): Promise<void> 参数
- filePath: string
- content: string
返回 Promise<void>
readBuffer
readBuffer(filePath: string): Promise<Buffer<ArrayBufferLike> | null> 返回 Promise<Buffer<ArrayBufferLike> | null>
writeBuffer
writeBuffer(filePath: string, data: Buffer): Promise<void> 参数
- filePath: string
- data: Buffer
返回 Promise<void>
readDir
readDir(dirPath: string): Promise<string[]>
exists
exists(filePath: string): Promise<boolean>
mkdir
mkdir(dirPath: string): Promise<void>
remove
remove(filePath: string): Promise<void>
removeDir
removeDir(dirPath: string): Promise<void>
stat
stat(filePath: string): Promise<Stats | null>
copy
copy(src: string, dest: string): Promise<void>
readDirWithTypes
readDirWithTypes(dirPath: string): Promise<Dirent<string>[]> 返回 Promise<Dirent<string>[]>