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
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
name | readonly | string | The file name that this dirent represents, including the extension if applicable. | NVEDirent.name |
parentPath | readonly | string | The parent directory path of this dirent. | NVEDirent.parentPath |
Accessors
content
Get Signature
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
dirty
Get Signature
get dirty(): boolean;NVEDirent.dirty
Returns
boolean
Overrides
extension
Get Signature
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
icon
Get Signature
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
iconDark
Get Signature
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
iconDarkOpened
Get Signature
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
iconOpened
Get Signature
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
isDisposed
Get Signature
get isDisposed(): boolean;Returns true if this entry has been disposed and is no longer usable.
Returns
boolean
Overrides
language
Get Signature
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
lastModified
Get Signature
get lastModified(): Date;Returns the last modified date of this entry Throws CannotAccessDisposedDirectException if the entry is disposed.
Returns
Date
Overrides
path
Get Signature
get path(): string;The full path of the entry, computed from parentPath and name.
Returns
string
Overrides
uri
Get Signature
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
virtual
Get Signature
get virtual(): boolean;Indicates that this dirent entry is virtual.
Returns
boolean
Overrides
Methods
asModel()
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
| Parameter | Type | Description |
|---|---|---|
editor | typeof editor | The Monaco editor module to use for model creation. |
Returns
ITextModel
The Monaco ITextModel instance for this file.
Inherited from
commit()
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
const file = new NVEDirent({ name: 'foo.txt', parentPath: '/', onCommit: async (d) => { ... } })
await file.commit()Inherited from
dispose()
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
isBlockDevice()
isBlockDevice(): boolean;Returns true if the fs.Dirent object describes a block device.
Returns
boolean
Since
v10.10.0
Inherited from
isCharacterDevice()
isCharacterDevice(): boolean;Returns true if the fs.Dirent object describes a character device.
Returns
boolean
Since
v10.10.0
Inherited from
isDirectory()
isDirectory(): boolean;Returns true if the fs.Dirent object describes a file system directory.
Returns
boolean
Since
v10.10.0
Inherited from
isFIFO()
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
isFile()
isFile(): boolean;Returns true if the fs.Dirent object describes a regular file.
Returns
boolean
Since
v10.10.0
Inherited from
isSocket()
isSocket(): boolean;Returns true if the fs.Dirent object describes a socket.
Returns
boolean
Since
v10.10.0
Inherited from
isSymbolicLink()
isSymbolicLink(): boolean;Returns true if the fs.Dirent object describes a symbolic link.
Returns
boolean
Since
v10.10.0
Inherited from
isVirtual()
isVirtual(): boolean;Indicates that this dirent entry is virtual.
Returns
boolean
Always returns true for virtual entries.
Overrides
offCommitError()
offCommitError(callback: (error: unknown, dirent: NVEDirent) => void): void;Removes a previously registered commit error callback.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (error: unknown, dirent: NVEDirent) => void | The function to remove from the commitError event listeners. |
Returns
void
Example
const handler = (err, dirent) => { ... }
file.onCommitError(handler)
// ...
file.offCommitError(handler)Inherited from
onceCommitError()
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
| Parameter | Type | Description |
|---|---|---|
callback | (error: unknown, dirent: NVEDirent) => void | The function to call on the next commit error. Receives the error and the dirent instance. |
Returns
void
Example
file.onceCommitError((err, dirent) => {
alert("First commit failure!");
});Inherited from
onCommitError()
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
| Parameter | Type | Description |
|---|---|---|
callback | (error: unknown, dirent: NVEDirent) => void | The function to call on commit error. Receives the error and the dirent instance. |
Returns
void
Example
file.onCommitError((err, dirent) => {
console.error("Commit failed:", err);
});Inherited from
onWillDispose()
onWillDispose(callback: (dirent: NVEDirent) => void): void;Registers a callback to be invoked when this entry is disposed. The callback is only called once.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (dirent: NVEDirent) => void | The function to call when disposed. |
Returns
void
Inherited from
toSerialized()
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.