Overview
The Singleton is designed to facilitate the developer to manipulate the file path. cc.pathThe purpose of the definition is to nodejs path keep it consistent. The API defined in it is basically nodejs the path same as the module, but not all, and may continue to be added as needed in the future. Also added are some path modules that do not have Pai, for example cc.path.changeExtname and cc.path.changeBasename .
Cc.path.join
Path stitching operation.
Parameters:
Name
Type
Variable-length parameters
String
Cc.path.extname
Gets the suffix name of the file path.
Parameters:
Name
Type
Pathstr
String
Cc.path.basename
Gets the file name.
Parameters:
Name
Type
Remark
Pathstr
String
Must fill in
Extname
String
Optional, specifies the name of the suffix to be removed from the file name, and does not consider removing the suffix name
Cc.path.driname
Gets the folder path where the file resides.
Parameters:
Name
Type
Remark
Pathstr
String
Required, File path
Cc.path.changeExtname
Change the file suffix name.
Parameters:
Name
Type
Remark
Pathstr
String
Must fill in
Extname
String
Specifies the suffix name to be modified, not the suffix name
Cc.path.changeBasename
Change the file name.
Parameters:
Name
Type
Remark
Pathstr
String
Must fill in
BaseName
String
Specifies the suffix name to be modified, not the suffix name
Issameext
Boolean
Whether the same suffix name is guaranteed
Example
See tests the PathTest test examples in.
"COCOS2D-JS official documents" Xi. Cc.path