跳到主要内容

RES.path.globalFunction

公共方法

方法
basename(filename:string):string
根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts"
dirname(path:string):string
文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B"
normalize(filename:string):string
格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts"

方法详细信息

basename()

public basename(filename:string):string

根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts"

  • 支持版本:Egret 5.2

  • 运行平台:Web,Native

  • 参数

    • filename:string - 传入的文件路径
  • 返回:文件的名字

dirname()

public dirname(path:string):string

文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B"

  • 支持版本:Egret 5.2

  • 运行平台:Web,Native

  • 参数

  • 返回:文件所在文件夹的地址

normalize()

public normalize(filename:string):string

格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts"

  • 支持版本:Egret 5.2
  • 运行平台:Web,Native
  • 参数
    • filename:string - 传入的文件路径