Skip to content

Interface: NVEVirtualDirent

Represents a virtual dirent entry.

This class extends NVEDirent to provide a representation of a dirent entry that does not exist on disk, but is used virtually within the application.

Extends

Properties

PropertyModifierTypeDescriptionInherited from
namereadonlystringThe file name that this dirent represents, including the extension if applicable.NVEDirent.name
parentPathreadonlystringThe parent directory path of this dirent.NVEDirent.parentPath

Accessors

content

Get Signature

ts
get content(): string;

The file contents as a string. Setting this will update the Monaco model if present. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

string

Overrides

NVEDirent.content


dirty

Get Signature

ts
get dirty(): boolean;

NVEDirent.dirty

Returns

boolean

Overrides

NVEDirent.dirty


extension

Get Signature

ts
get extension(): string | undefined;

Returns the file extension (without the dot) if this is a file, otherwise undefined. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

string | undefined

Overrides

NVEDirent.extension


icon

Get Signature

ts
get icon(): string;

Returns the icon URL for this entry based on its type and name. If this is a directory, it uses the folder icon; otherwise, it uses the file icon. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

string

Overrides

NVEDirent.icon


iconDark

Get Signature

ts
get iconDark(): string;

Returns the icon URL for this entry based on its type and name. If this is a directory, it uses the folder icon; otherwise, it uses the file icon. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

string

Overrides

NVEDirent.iconDark


iconDarkOpened

Get Signature

ts
get iconDarkOpened(): string;

Returns the icon URL for this entry when it is in an "opened" state. This is typically used for directories to indicate they are expanded. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

string

Overrides

NVEDirent.iconDarkOpened


iconOpened

Get Signature

ts
get iconOpened(): string;

Returns the icon URL for this entry when it is in an "opened" state. This is typically used for directories to indicate they are expanded. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

string

Overrides

NVEDirent.iconOpened


isDisposed

Get Signature

ts
get isDisposed(): boolean;

Returns true if this entry has been disposed and is no longer usable.

Returns

boolean

Overrides

NVEDirent.isDisposed


language

Get Signature

ts
get language(): NVEDirentLanguage | undefined;

Returns the Monaco language identifier inferred from the file extension, if this is a file. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

NVEDirentLanguage | undefined

Overrides

NVEDirent.language


lastModified

Get Signature

ts
get lastModified(): Date;

Returns the last modified date of this entry Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

Date

Overrides

NVEDirent.lastModified


path

Get Signature

ts
get path(): string;

The full path of the entry, computed from parentPath and name.

Returns

string

Overrides

NVEDirent.path


uri

Get Signature

ts
get uri(): Uri;

Returns the Monaco Editor Uri for this file, creating and caching it if necessary. Throws CannotAccessDisposedDirectException if the entry is disposed.

Returns

Uri

Overrides

NVEDirent.uri


virtual

Get Signature

ts
get virtual(): boolean;

Indicates that this dirent entry is virtual.

Returns

boolean

Overrides

NVEDirent.virtual

Methods

asModel()

ts
asModel(editor: typeof editor): ITextModel;

Returns the Monaco Editor ITextModel for this file, creating it if necessary. The model is kept in sync with the file's content and is disposed automatically. Throws CannotAccessDisposedDirectException if the entry is disposed.

Parameters

ParameterTypeDescription
editortypeof editorThe Monaco editor module to use for model creation.

Returns

ITextModel

The Monaco ITextModel instance for this file.

Inherited from

NVEDirent.asModel


commit()

ts
commit(): Promise<boolean>;

Commits (saves) the current file using the provided commit handler.

This method invokes the user-provided NVECommitDirent hook (if defined) to persist changes. If the commit succeeds, returns true; otherwise, emits a commitError event and returns false.

Returns

Promise<boolean>

A Promise resolving to true if the commit succeeded, or false if it failed.

Throws

If the dirent is disposed.

Throws

If no commit handler is defined.

Example

ts
const file = new NVEDirent({ name: 'foo.txt', parentPath: '/', onCommit: async (d) => { ... } })
await file.commit()

Inherited from

NVEDirent.commit


dispose()

ts
dispose(): void;

Disposes of this entry, cleaning up all resources and notifying listeners. Emits the disposed event and throws on further access.

Returns

void

Inherited from

NVEDirent.dispose


isBlockDevice()

ts
isBlockDevice(): boolean;

Returns true if the fs.Dirent object describes a block device.

Returns

boolean

Since

v10.10.0

Inherited from

NVEDirent.isBlockDevice


isCharacterDevice()

ts
isCharacterDevice(): boolean;

Returns true if the fs.Dirent object describes a character device.

Returns

boolean

Since

v10.10.0

Inherited from

NVEDirent.isCharacterDevice


isDirectory()

ts
isDirectory(): boolean;

Returns true if the fs.Dirent object describes a file system directory.

Returns

boolean

Since

v10.10.0

Inherited from

NVEDirent.isDirectory


isFIFO()

ts
isFIFO(): boolean;

Returns true if the fs.Dirent object describes a first-in-first-out (FIFO) pipe.

Returns

boolean

Since

v10.10.0

Inherited from

NVEDirent.isFIFO


isFile()

ts
isFile(): boolean;

Returns true if the fs.Dirent object describes a regular file.

Returns

boolean

Since

v10.10.0

Inherited from

NVEDirent.isFile


isSocket()

ts
isSocket(): boolean;

Returns true if the fs.Dirent object describes a socket.

Returns

boolean

Since

v10.10.0

Inherited from

NVEDirent.isSocket


ts
isSymbolicLink(): boolean;

Returns true if the fs.Dirent object describes a symbolic link.

Returns

boolean

Since

v10.10.0

Inherited from

NVEDirent.isSymbolicLink


isVirtual()

ts
isVirtual(): boolean;

Indicates that this dirent entry is virtual.

Returns

boolean

Always returns true for virtual entries.

Overrides

NVEDirent.isVirtual


offCommitError()

ts
offCommitError(callback: (error: unknown, dirent: NVEDirent) => void): void;

Removes a previously registered commit error callback.

Parameters

ParameterTypeDescription
callback(error: unknown, dirent: NVEDirent) => voidThe function to remove from the commitError event listeners.

Returns

void

Example

ts
const handler = (err, dirent) => { ... }
file.onCommitError(handler)
// ...
file.offCommitError(handler)

Inherited from

NVEDirent.offCommitError


onceCommitError()

ts
onceCommitError(callback: (error: unknown, dirent: NVEDirent) => void): void;

Registers a callback to be invoked only once when a commit operation fails.

The callback will be called the next time a commitError event is emitted, then automatically removed.

Parameters

ParameterTypeDescription
callback(error: unknown, dirent: NVEDirent) => voidThe function to call on the next commit error. Receives the error and the dirent instance.

Returns

void

Example

ts
file.onceCommitError((err, dirent) => {
  alert("First commit failure!");
});

Inherited from

NVEDirent.onceCommitError


onCommitError()

ts
onCommitError(callback: (error: unknown, dirent: NVEDirent) => void): void;

Registers a callback to be invoked when a commit operation fails.

The callback will be called every time a commitError event is emitted (i.e., when the commit handler throws or rejects).

Parameters

ParameterTypeDescription
callback(error: unknown, dirent: NVEDirent) => voidThe function to call on commit error. Receives the error and the dirent instance.

Returns

void

Example

ts
file.onCommitError((err, dirent) => {
  console.error("Commit failed:", err);
});

Inherited from

NVEDirent.onCommitError


onWillDispose()

ts
onWillDispose(callback: (dirent: NVEDirent) => void): void;

Registers a callback to be invoked when this entry is disposed. The callback is only called once.

Parameters

ParameterTypeDescription
callback(dirent: NVEDirent) => voidThe function to call when disposed.

Returns

void

Inherited from

NVEDirent.onWillDispose


toSerialized()

ts
toSerialized(): Promise<string>;

Serializes this NVEDirent instance to a compact, base64-encoded string.

The output includes the name, parentPath, content, and lastModified fields, and is prefixed for identification. This is suitable for storage, sharing, or persistence of file system state.

Returns

Promise<string>

A base64-encoded string representing the serialized dirent.

Inherited from

NVEDirent.toSerialized