Editor.Model.SourcePath
ClassRepresents a file path within a Lens Studio project, combining a root-relative path with a source root directory.
Index
Properties
Methods
Example
const sp = new Editor.Model.SourcePath(
new Editor.Path('Textures/logo.png'),
Editor.Model.SourceRootDirectory.Assets
);
console.log(`toString: ${sp.toString()}`);
console.log(`extension: ${sp.extension}`);
console.log(`fileName: ${sp.fileName}`);
console.log(`fileNameBase: ${sp.fileNameBase}`);
console.log(`isEmpty: ${sp.isEmpty}`);
console.log(`parent: ${sp.parent}`);
console.log(`relativeToProject: ${sp.relativeToProject}`);
console.log(`relativeToRoot: ${sp.relativeToRoot}`);
console.log(`rootDirectory: ${sp.rootDirectory}`);
console.log(`hasExtension('.png'): ${sp.hasExtension('.png')}`);
console.log(`hasExtension('.jpg'): ${sp.hasExtension('.jpg')}`);
const replaced = sp.replaceFileNameBase('icon');
console.log(`After replaceFileNameBase('icon'): ${replaced.toString()}`);
Constructors
Constructor
new SourcePath(
relativeToRoot,rootDirectory):SourcePath
Constructs a SourcePath specifying a relative path and root directory within the asset file system.
Parameters
| Parameter | Type |
|---|---|
relativeToRoot | Path |
rootDirectory | SourceRootDirectory |
Returns
SourcePath
Properties
extension
readonlyextension:string
File extension of the path, including the leading dot.
fileName
readonlyfileName:Path
File name portion of the path as an Editor.Path.
fileNameBase
readonlyfileNameBase:string
File name without extension.
isEmpty
readonlyisEmpty:boolean
True if the path is empty or unset.
parent
readonlyparent:SourcePath
Parent directory of the path as a SourcePath.
relativeToProject
readonlyrelativeToProject:Path
Path relative to the project root.
relativeToRoot
readonlyrelativeToRoot:Path
Path relative to the source root directory.
rootDirectory
readonlyrootDirectory:Path
Source root directory this path is anchored to.
Methods
hasExtension()
hasExtension(
extension):boolean
Returns true if the path's file extension matches the given extension string.
Parameters
| Parameter | Type |
|---|---|
extension | string |
Returns
boolean
replaceFileNameBase()
replaceFileNameBase(
newBaseName):SourcePath
Returns a new SourcePath with the file name base replaced by the given string.
Parameters
| Parameter | Type |
|---|---|
newBaseName | string |
Returns
SourcePath
toString()
toString():
string
Returns the full path as a string.
Returns
string