decord/alpha/source/utils/PathUtils.tsx

49 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 14625
// Function ID: 14626
// Name: PathUtils
2026-10-09 10:00:15 +00:00
// Dependencies: [1382, 2]
2026-07-29 08:29:29 +00:00
// Exports: pathBasename, pathFilenameWithoutExt, pathJoin
2026-07-20 16:05:17 +00:00
2026-10-13 12:43:34 +00:00
// Module 14625 (PathUtils)
2026-10-09 10:00:15 +00:00
import PlatformUtils from "PlatformUtils" /* 1382 */;
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
const result = size.fileFinishedImporting("utils/PathUtils.tsx");
2026-07-29 08:29:29 +00:00
export const pathJoin = function pathJoin() {
2026-07-29 08:29:29 +00:00
const items = [...arguments];
let str = "/";
2026-10-03 08:58:59 +00:00
const obj = PlatformUtils;
2026-07-29 08:29:29 +00:00
if (obj.isWindows()) {
str = "\\";
}
const found = items.filter((item) => item.length > 0);
2026-07-29 08:29:29 +00:00
return found.join(str);
};
export const pathBasename = function pathBasename(str, arg1) {
2026-07-20 16:05:17 +00:00
let arr = str;
const parts = str.split(/[/\\]/);
if ("" !== parts[parts.length - 1]) {
arr = parts[parts.length - 1];
}
let substr = arr;
2026-10-03 08:58:59 +00:00
const tmp = null != arg1 && arr.endsWith(arg1);
2026-07-20 16:05:17 +00:00
if (tmp) {
substr = arr.slice(0, -arg1.length);
}
return substr;
};
2026-07-29 08:29:29 +00:00
export const pathFilenameWithoutExt = function pathFilenameWithoutExt(str) {
let arr = str;
const parts = str.split(/[/\\]/);
if ("" !== parts[parts.length - 1]) {
arr = parts[parts.length - 1];
}
2026-07-20 16:05:17 +00:00
const lastIndexOfResult = arr.lastIndexOf(".");
let substr = arr;
if (lastIndexOfResult > 0) {
substr = arr.slice(0, lastIndexOfResult);
}
return substr;
};