bd8a015d9f05319ae091f7383c093a5f26a12133.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, PathUtil, _crd;
  4. _export("default", void 0);
  5. return {
  6. setters: [function (_cc) {
  7. _cclegacy = _cc.cclegacy;
  8. }],
  9. execute: function () {
  10. _crd = true;
  11. _cclegacy._RF.push({}, "599009CYiRPSbP+6MJkFWLY", "PathUtil", undefined);
  12. _export("default", PathUtil = class PathUtil {
  13. /**
  14. * 返回 Path 的扩展名
  15. * @param path 路径
  16. * @returns {string}
  17. */
  18. static extname(path) {
  19. var temp = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(path);
  20. return temp ? temp[1] : '';
  21. }
  22. /**
  23. * 获取文件路径的文件名。
  24. * @param path 路径
  25. * @param extname 扩展名
  26. * @returns {string}
  27. */
  28. static basename(path, extname) {
  29. let index = path.indexOf("?");
  30. if (index > 0) path = path.substring(0, index);
  31. let reg = /(\/|\\)([^\/\\]+)$/g;
  32. let result = reg.exec(path.replace(/(\/|\\)$/, ""));
  33. if (!result) return path;
  34. let baseName = result[2];
  35. if (extname && path.substring(path.length - extname.length).toLowerCase() === extname.toLowerCase()) return baseName.substring(0, baseName.length - extname.length);
  36. return baseName;
  37. }
  38. /**
  39. * 获取文件路径的目录名
  40. * @param path 路径
  41. * @returns {string}
  42. */
  43. static dirname(path) {
  44. var temp = /((.*)(\/|\\|\\\\))?(.*?\..*$)?/.exec(path);
  45. return temp ? temp[2] : '';
  46. }
  47. });
  48. _cclegacy._RF.pop();
  49. _crd = false;
  50. }
  51. };
  52. });
  53. //# sourceMappingURL=bd8a015d9f05319ae091f7383c093a5f26a12133.js.map