概述
文件系统常用的函数集合
目录
- GlobWhere (类型)
- clearFolder (函数)
- createFile (函数)
- createFolder (函数)
- deleteFile (函数)
- deleteFolder (函数)
- existFile (函数)
- existFolder (函数)
- file (函数)
- fileStream (函数)
- fileString (函数)
- folders (函数)
- glob (函数)
- updateFile (函数)
- updateFolder (函数)
GlobWhere (类型)
签名
export type GlobWhere = { path: string[] | string; options?: GlobOptions }
clearFolder (函数)
删除目录即使目录包含文件
签名
export const clearFolder = (strPath: string): void => ...
v0.2.0 中添加
createFile (函数)
写入一个文件
签名
export const createFile = (
{ path, data, encoding }: { path: string, data: string | Buffer, encoding?: string }): void => ...
v0.2.0 中添加
createFolder (函数)
创建一个目录。 当目录不存在时,建立目录。 目录存在,忽略
签名
export const createFolder = (path: string): void => ...
v0.2.0 中添加
deleteFile (函数)
删除一个文件
签名
export const deleteFile = (path: string): void => ...
v0.2.0 中添加
deleteFolder (函数)
删除目录即使目录包含文件
签名
export const deleteFolder = (strPath: string): void => ...
v0.2.0 中添加
existFile (函数)
判断文件是否存在
签名
export const existFile = (path: string): boolean => ...
v0.2.0 中添加
existFolder (函数)
核对指定的目录是否存在
签名
export const existFolder = (path: string): boolean => ...
v0.2.0 中添加
file (函数)
得到一个文件信息
签名
export const file = (path: string): {
path: string
size: number
lastModified: Date
} => ...
v0.2.0 中添加
fileStream (函数)
得到一个文件流
签名
export const fileStream = (path: string): fs.ReadStream => ...
v0.2.0 中添加
fileString (函数)
得到一个文本文件
签名
export const fileString = (path: string): string => ...
v0.2.0 中添加
folders (函数)
在指定的目录下列出所有的目录和文件
签名
export const folders = (strPath: string): { folders: string[], files: string[] } => ...
v0.2.0 中添加
glob (函数)
寻找文件或目录
签名
export const glob = ({ path, options }: GlobWhere): string[] => ...
v0.2.0 中添加
updateFile (函数)
更新一个文件
当path
不为空时,重命名文件用这个值
当data
不为空时,替换文件内容
签名
export const updateFile = ({ data: { path, data, encoding }, where }:
{ data: { path?: string, data?: string | Buffer, encoding?: string }, where: string }): void => ...
v0.2.0 中添加
updateFolder (函数)
重新命名一个存在的目录
签名
export const updateFolder = ({ name, where }: { name: string, where: string }): void => ...
v0.2.0 中添加