mfw-fs
v1.0.7
Published
file system of minerframework
Downloads
2
Readme
这是一个文件的npm包,基于node fs模块扩展
/**
* 写入文件
* @param path
* @param data
* @param options
*/
export declare function writeFile(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
/**
* 读取文件
* @param path
* @param options
* @returns
*/
export declare function readFile(path: PathOrFileDescriptor, options?: {
encoding: BufferEncoding;
flag?: string | undefined;
}): string | Buffer;
/**
* 重命名文件
* @param oldPath
* @param newPath
* @returns
*/
export declare function rename(oldPath: string, newPath: string): void;
/**
* 删除文件&目录
* @param path
*/
export declare function rm(path: PathLike): void;
/**
* 创建目录
* @param path
* @returns
*/
export declare function mkdir(path: string): string | undefined;
/**
* 判断路径是否为文件
* @param path
* @returns
*/
export declare function isFile(path: string): boolean;
/**
* 判断路径是否为目录
* @param path
* @returns
*/
export declare function isDirectory(path: string): boolean;
/**
* 列出目录下的文件列表
* @param dir
* @param recursively 是否递归
* @param callback 文件回调
* @returns
*/
export declare function ls(dir: string, recursively?: boolean, callback?: (filePath: string) => void): void;
/**
* 拷贝文件/文件夹
* @param src
* @param dest
*/
export declare function cp(src: string, dest: string): void;
/**
* 获取文件&目录的大小
* @param path
* @returns
*/
export declare function size(path: string): number;
/**
* 根据条件筛选目录下的文件
* @param path
* @param recursively
* @param callback
* @param output
* @returns
*/
export declare function filterls(path: string, recursively: boolean | undefined, callback: (filePath: string) => boolean, output?: Array<string>): string[];
/**
* 读取json文件
* @param jsonPath
* @param defaultValue
* @returns
*/
export declare function readJson(jsonPath: string, defaultValue?: any): any;
/**
* 写入json文件
* @param jsonPath
* @param data
*/
export declare function writeJson(jsonPath: string, data: any): void;
/**
* 获取文件md5值
* @param path
* @returns
*/
export declare function getMd5(path: string): string;