71 lines
1.3 KiB
Markdown
71 lines
1.3 KiB
Markdown
## fs
|
|
|
|
```ts
|
|
interface FsPackage {
|
|
/**
|
|
* get directory path of api config file
|
|
*
|
|
*/
|
|
configDir(): string
|
|
|
|
/**
|
|
* read a file relative to config dir and return its content
|
|
*
|
|
* @param path relative file path
|
|
* @param options optional options
|
|
*/
|
|
readFile(
|
|
path: string,
|
|
options?: {
|
|
bytes: boolean // if true return []byte instead of string
|
|
}
|
|
): string | any
|
|
|
|
/**
|
|
* write data to a file relative to config dir
|
|
*
|
|
* @param path relative file path
|
|
* @param data string or []byte data
|
|
*/
|
|
writeFile(path: string, data: string | any): null
|
|
|
|
/**
|
|
* stat file or directory
|
|
*
|
|
* @param path
|
|
*/
|
|
stat(path: string): {
|
|
name: string
|
|
size: number
|
|
isDir: boolean
|
|
modTime: string
|
|
}
|
|
|
|
/**
|
|
* list directory entries
|
|
*
|
|
* @param path
|
|
*/
|
|
readDir(path: string): {
|
|
name: string
|
|
size: number
|
|
isDir: boolean
|
|
modTime: string
|
|
}[]
|
|
|
|
/**
|
|
* make directory and all missing sub directories, no error if directory already exists
|
|
*
|
|
* @param path
|
|
*/
|
|
mkDir(path: string): void
|
|
|
|
/**
|
|
* remove file or empty directory
|
|
*
|
|
* @param path
|
|
*/
|
|
remove(path: string): void
|
|
}
|
|
```
|