Skip to main content

Editor.Path

Class

A path in the filesystem, or Asset Manager.

A path in the filesystem, or Asset Manager. Useful for things like importing files into Lens Studio through the Editor.Model.AssetManager.

Index

Example

// Get access to the project's assetManager
const model = this.pluginSystem.findInterface(Editor.Model.IModel);
const assetManager = model.project.assetManager;

// Locate the shader pass we want to import
const resourceLoc = import.meta.resolve('Resources/myMesh.ss_graph');
const absGraphPath = new Editor.Path(resourceLoc);

// Import the shader pass
const pathInAssetManager = new Editor.Path('');
const meta = await assetManager.importExternalFileAsync(absolutePath, pathInAssetManager, Editor.Model.ResultType.Packed);

Constructors

Constructor

new Path(str): Path

Construct a new path object.

Parameters

ParameterType
strstring

Returns

Path

Properties

extension

readonly extension: string

The extension of the file of the current path object (without dot).


fileName

readonly fileName: Path

The name of the file, including its extension, in the current path object.


fileNameBase

readonly fileNameBase: string

The name of the file, without its extension, in the current path object.


isEmpty

readonly isEmpty: boolean

Whether the path string is empty.


parent

readonly parent: Path

A path to the parent folder of the current path object.

Methods

appended()

appended(path): Path

Returns a new path object relative to the rootPath.

Parameters

ParameterType
pathPath

Returns

Path


equals()

static equals(lhs, rhs): boolean

Returns true if this path is equal to the given path.

Parameters

ParameterType
lhsPath
rhsPath

Returns

boolean


hasExtension()

hasExtension(extension): boolean

Whether the path object has a file extension in the end.

Parameters

ParameterType
extensionstring

Returns

boolean


isInside()

isInside(directory): boolean

Whether the current path is inside directory.

Parameters

ParameterType
directoryPath

Returns

boolean


relative()

relative(rootPath): Path

Returns a new path object relative to the rootPath.

Parameters

ParameterType
rootPathPath

Returns

Path


replaceExtension()

replaceExtension(newExtension): Path

Rename the extension of the file.

Parameters

ParameterType
newExtensionstring

Returns

Path


replaceFileNameBase()

replaceFileNameBase(name): Path

Returns a new path with the file name base replaced by the given string, preserving extension and directory.

Parameters

ParameterType
namestring

Returns

Path


toString()

toString(): string

Returns the current path as a string.

Returns

string