decord/stable/source/utils/PathUtils.tsx

49 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2026-10-06 22:12:49 +00:00
// Module ID: 13538
// Function ID: 13539
// Name: PathUtils
2026-10-06 22:12:49 +00:00
// Dependencies: [1370, 2]
// Exports: pathBasename, pathFilenameWithoutExt, pathJoin
2026-10-06 22:12:49 +00:00
// Module 13538 (PathUtils)
import PlatformUtils from "PlatformUtils" /* 1370 */;
import size from "module_2" /* 2 */;
const result = size.fileFinishedImporting("utils/PathUtils.tsx");
export const pathJoin = function pathJoin() {
const items = [...arguments];
let str = "/";
2026-10-06 22:12:49 +00:00
const obj = PlatformUtils;
if (obj.isWindows()) {
str = "\\";
}
const found = items.filter((item) => item.length > 0);
return found.join(str);
};
export const pathBasename = function pathBasename(str, arg1) {
let arr = str;
const parts = str.split(/[/\\]/);
if ("" !== parts[parts.length - 1]) {
arr = parts[parts.length - 1];
}
let substr = arr;
2026-10-06 22:12:49 +00:00
const tmp = null != arg1 && arr.endsWith(arg1);
if (tmp) {
substr = arr.slice(0, -arg1.length);
}
return substr;
};
export const pathFilenameWithoutExt = function pathFilenameWithoutExt(str) {
let arr = str;
const parts = str.split(/[/\\]/);
if ("" !== parts[parts.length - 1]) {
arr = parts[parts.length - 1];
}
const lastIndexOfResult = arr.lastIndexOf(".");
let substr = arr;
if (lastIndexOfResult > 0) {
substr = arr.slice(0, lastIndexOfResult);
}
return substr;
};