/** * 获取指定路径对应的绝对路径 * @param paths 要处理的路径 * @returns 返回以 `/`(非 Windows) 或 `\`(Windows) 为分隔符的绝对路径,路径末尾多余的分隔符会被删除 * @example resolvePath("foo/goo/hoo", "../relative") */ export declare function resolvePath(...paths: readonly string[]): string; /** * 获取指定路径对应的相对路径 * @param base 要使用的基路径 * @param path 要处理的路径 * @returns 返回以 `/` 为分隔符的相对路径,路径末尾多余的分隔符会被删除 * @example relativePath("foo/goo/hoo", "foo/goo/relative") // "../relative" */ export declare function relativePath(base: string, path: string): string; /** * 合并多个路径 * @param paths 要处理的路径 * @returns 返回以 `/`(非 Windows) 或 `\`(Windows) 为分隔符的绝对路径或以 `/` 为分隔符的相对路径,路径末尾多余的分隔符会被保留 * @example joinPath("a", "b") // "a/b" */ export declare function joinPath(...paths: readonly string[]): string; /** * 规范化指定的路径 * @param path 要处理的路径 * @returns 返回以 `/`(非 Windows) 或 `\`(Windows) 为分隔符的绝对路径或以 `/` 为分隔符的相对路径,路径末尾多余的分隔符会被保留 * @example normalizePath("./foo/") // "foo/" */ export declare function normalizePath(path: string): string; /** * 判断指定的路径是否是绝对路径 * @param path 要判断的路径 * @example isAbsolutePath("foo") // false */ export declare function isAbsolutePath(path: string): boolean; /** * 获取指定路径的文件夹部分 * @param path 要处理的路径 * @example getDir("/root/foo.txt") // "/root" */ export declare function getDir(path: string): string; /** * 设置指定路径的文件夹部分 * @param path 要处理的路径 * @param value 要设置的新文件夹路径 * @param base 如果提供了原文件夹路径,则保留文件在原文件夹内的路径 * @returns 如果新文件夹路径是绝对路径,返回以 `/`(非 Windows) 或 `\`(Windows) 为分隔符的绝对路径,否则返回以 `/` 为分隔符的相对路径 * @example setDir("/root/foo.txt", "goo") // "goo/foo.txt" * @example setDir("/root/goo/foo.txt", "/user", "/root") // "/user/goo/foo.txt" */ export declare function setDir(path: string, value: string, base?: string): string; /** * 获取指定路径的根部分 * @param path 要处理的路径 * @example getRoot("/root/goo/foo.txt") // "/root" */ export declare function getRoot(path: string): string; /** * 设置指定路径的根部分 * @param path 要处理的路径 * @example setRoot("/root/goo/foo.txt", "/user") // "/user/goo/foo.txt" */ export declare function setRoot(path: string, value: string): string; /** * 获取指定路径的文件名部分 * @param path 要处理的路径 * @param includeExt 如果为 `true`(默认)则包含扩展名(含点),否则不包含扩展名 * @example getName("/root/foo.txt") // "foo.txt" * @example getName("/root/foo.txt", false) // "foo" */ export declare function getName(path: string, includeExt?: boolean): string; /** * 设置指定路径的文件名部分 * @param path 要处理的路径 * @param value 要更改的新文件名 * @param includeExt 如果为 `true`(默认)则同时更改扩展名(含点),否则保留原扩展名 * @example setName("/root/foo.txt", "goo.jpg") // "/root/goo.jpg" * @example setName("/root/foo.txt", "goo", false) // "/root/goo.jpg" */ export declare function setName(path: string, value: string, includeExt?: boolean): string; /** * 在指定路径的文件名前追加内容 * @param path 要处理的路径 * @param value 要追加的内容 * @example prependName("foo/goo.txt", "fix_") // "foo/fix_goo.txt" */ export declare function prependName(path: string, value: string): string; /** * 在指定路径的文件名(不含扩展名部分)后追加内容 * @param path 要处理的路径 * @param value 要追加的内容 * @example appendName("foo/goo.src.txt", "_fix") // "foo/goo_fix.src.txt" */ export declare function appendName(path: string, value: string): string; /** * 在指定路径的文件名(不含扩展名部分)后追加索引 * @param path 要处理的路径 * @param index 要追加的索引,其中的数字会递增 * @example appendIndex("foo/goo.src.txt") // "foo/goo_2.src.txt" * @example appendIndex("foo/goo_2.src.txt") // "foo/goo_3.src.txt" */ export declare function appendIndex(path: string, index?: string): string; /** * 计算重命名后的路径 * @params path 目标字段 * @params append 转换附加字符串 * @params ext 排除的扩展名 * @example getNewPath("测试 - 副本", " - 副本") // "测试 - 副本2" * @example getNewPath("test", "-2") // "test-2" * @example getNewPath("test-2", "-2") // "test-3" */ export declare function getNewPath(path: string, append?: string, ext?: string): string; /** * 获取指定路径的扩展名(含点)部分 * @param path 要处理的地址 * @example getExt("/root/foo.txt") // ".txt" * @example getExt(".gitignore") // "" */ export declare function getExt(path: string): string; /** * 设置指定路径的扩展名(含点)部分,如果源路径不含扩展名则追加到末尾 * @param path 要处理的路径 * @param value 要更改的新扩展名(含点) * @example setExt("/root/foo.txt", ".jpg") // "/root/foo.jpg" * @example setExt("/root/foo.txt", "") // "/root/foo" * @example setExt("/root/foo", ".jpg") // "/root/foo.jpg" */ export declare function setExt(path: string, value: string): string; /** 判断当前系统是否忽略路径的大小写 */ export declare const isCaseInsensitive: boolean; /** * 判断两个路径是否相同 * @param path1 要判断的第一个路径,路径必须已规范化 * @param path2 要判断的第二个路径,路径必须已规范化 * @param ignoreCase 是否忽略路径的大小写 * @example pathEquals("/root", "/root") // true */ export declare function pathEquals(path1: string, path2: string, ignoreCase?: boolean): boolean; /** * 判断指定的文件夹是否包含另一个文件或文件夹 * @param parent 要判断的父文件夹路径,路径必须已规范化 * @param child 要判断的子文件或文件夹路径,路径必须已规范化 * @param ignoreCase 是否忽略路径的大小写 * @example containsPath("/root", "/root/foo") // true * @example containsPath("/root/foo", "/root/goo") // false */ export declare function containsPath(parent: string, child: string, ignoreCase?: boolean): boolean; /** * 获取两个路径中最深的路径,如果没有公共部分则返回 `null` * @param path1 要处理的第一个路径,路径必须已规范化 * @param path2 要处理的第二个路径,路径必须已规范化 * @param ignoreCase 是否忽略路径的大小写 * @example deepestPath("/root", "/root/foo") // "/root/foo" */ export declare function deepestPath(path1: string | null | undefined, path2: string | null | undefined, ignoreCase?: boolean): string; /** * 获取两个路径的公共文件夹,如果没有公共部分则返回 `null` * @param path1 要处理的第一个路径,路径必须已规范化 * @param path2 要处理的第二个路径,路径必须已规范化 * @param ignoreCase 是否忽略路径的大小写 * @example commonDir("/root/foo", "/root/foo/goo") // "/root/foo" */ export declare function commonDir(path1: string | null | undefined, path2: string | null | undefined, ignoreCase?: boolean): string;