ez-common-ts/lib/commons/file-util.d.ts
2023-11-14 16:17:22 +08:00

44 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 获取文件的后缀名
* @param fileName 文件名
* @returns 文件后缀名
*/
export declare function getFileExt(fileName: string): string;
/**
* 获取文件全名(包含扩展名)
* 该函数接收一个表示文件路径的字符串作为参数,返回该路径中文件名部分。
* 首先查找路径中最后一个斜杠或反斜杠的索引,若未找到则直接返回路径;
* 若找到则使用substring方法提取最后一个斜杠或反斜杠后面的字符串作为文件名并返回。
* @param path 文件路径
* @returns 文件全名(包含扩展名)
*/
export declare function getFileFullName(path: string): string;
/**
* 获取文件名不包含扩展名
*/
export declare function getFileNameWithoutExt(path: string): string;
/**
* 文件信息
*/
export interface IFileInfo {
/** 文件名(包含扩展名) */
fileName: string;
/**
* 文件名不带扩展名
*/
fileNameNoExt: string;
/** 文件扩展名 */
fileExtName: string;
/** 路径仅包含文件夹 */
pathOnly: string;
/** 完整路径 */
fullPath: string;
}
/**
* 获取文件信息
* @param path 文件路径
* @param platform 平台名称,默认为"win32"
* @returns 包含文件名、文件名不带扩展名、文件扩展名、路径仅包含文件夹、完整路径的对象
*/
export declare function getFileInfo(path: string, platform?: string): IFileInfo;