Skip to content

Class VirtualFile

Source: virtualFile.ts

A virtual file that can be stored inside a folder.

Extends

Extended by

Constructors

Constructor

new VirtualFile(name: string, extension?: string): VirtualFile

Parameters

name

string

extension?

string

Returns

VirtualFile

Overrides

VirtualBase.constructor

Properties

extension

extension: OptionalStringProperty

The extension of this file.


source

source: OptionalStringProperty

The URL of the source of this file.


content

content: OptionalStringProperty

The content of this file.


NON_TEXT_EXTENSIONS

static NON_TEXT_EXTENSIONS: string[]


CONTENT_CHANGE_EVENT

readonly static CONTENT_CHANGE_EVENT: "contentChange" = "contentChange"


name

name: string

The name of this item.

Inherited from

VirtualBase.name


alias

alias: string | null | undefined

The alias of this item.

Inherited from

VirtualBase.alias


parent

parent: VirtualFolder<VirtualBaseEvents> | null | undefined

The folder this item is in.

Inherited from

VirtualBase.parent


isProtected

isProtected: boolean | null | undefined

Whether this item is protected from changes.

Inherited from

VirtualBase.isProtected


iconUrl

iconUrl: string | null | undefined

The URL of the icon of this item.

Inherited from

VirtualBase.iconUrl


linkedFile

linkedFile: VirtualFile | null | undefined

The file this item links to.

Inherited from

VirtualBase.linkedFile


linkedFolder

linkedFolder: VirtualFolder<VirtualBaseEvents> | null | undefined

The folder this item links to.

Inherited from

VirtualBase.linkedFolder


editedByUser

editedByUser: boolean | null | undefined

Whether this item has been edited by the user.

Inherited from

VirtualBase.editedByUser


isRoot

isRoot: boolean | null | undefined

Whether this item is the root folder.

Inherited from

VirtualBase.isRoot


root

root: VirtualRoot | null | undefined

The root folder.

Inherited from

VirtualBase.root


isDeleted

isDeleted: boolean

Whether this item has been deleted.

Inherited from

VirtualBase.isDeleted


UPDATE_EVENT

readonly static UPDATE_EVENT: "update" = "update"

Inherited from

VirtualBase.UPDATE_EVENT

Methods

setAlias()

setAlias(alias: string): this

Parameters

alias

string

Returns

this

Overrides

VirtualBase.setAlias


setSource()

setSource(source: string): this

Sets the source of this file and removes the content.

Parameters

source

string

Returns

this


setContent()

setContent(content: string | string[]): this

Sets the content of this file and removes the source.

Parameters

content

string | string[]

Returns

this


splitId()

static splitId(id: string): { name: string; extension: OptionalStringProperty; }

Parameters

id

string

Returns

{ name: string; extension: OptionalStringProperty; }

name

name: string

extension

extension: OptionalStringProperty


open()

open(windowsManager: WindowsManager): object | null

Opens this file in an app associated with its extension.

Parameters

windowsManager

WindowsManager

Returns

object | null

Overrides

VirtualBase.open


read()

read(): Promise<OptionalStringProperty>

Returns

Promise<OptionalStringProperty>


isFile()

isFile(): this is VirtualFile

Returns

this is VirtualFile

Overrides

VirtualBase.isFile


getIconUrl()

getIconUrl(): string

Returns

string

Overrides

VirtualBase.getIconUrl


getType()

getType(): string

Returns

string

Overrides

VirtualBase.getType


download()

download(): void

Returns

void


isDownloadable()

isDownloadable(): boolean

Returns

boolean


toJSON()

toJSON(): VirtualFileJson | null

Returns

VirtualFileJson | null

Overrides

VirtualBase.toJSON


removeFileScheme()

static removeFileScheme(source: string): string

Parameters

source

string

Returns

string


setName()

setName(name: string): this

Parameters

name

string

Returns

this

Inherited from

VirtualBase.setName


setParent()

setParent(parent: VirtualFolder): this

Parameters

parent

VirtualFolder

Returns

this

Inherited from

VirtualBase.setParent


setProtected()

setProtected(value: boolean): this

Parameters

value

boolean

Returns

this

Inherited from

VirtualBase.setProtected


setIconUrl()

setIconUrl(iconUrl: string | null): this

Parameters

iconUrl

string | null

Returns

this

Inherited from

VirtualBase.setIconUrl


delete()

delete(): void

Tries to delete this item.

Returns

void

Inherited from

VirtualBase.delete


confirmChanges()

confirmChanges(root?: VirtualRoot): void

Parameters

root?

VirtualRoot

Returns

void

Inherited from

VirtualBase.confirmChanges


getRoot()

getRoot(): VirtualRoot

Returns the root folder.

Returns

VirtualRoot

Inherited from

VirtualBase.getRoot


isFolder()

isFolder(): this is VirtualFolder<VirtualBaseEvents>

Returns

this is VirtualFolder<VirtualBaseEvents>

Inherited from

VirtualBase.isFolder


toString()

toString(): string | null

Returns a string representation of an object.

Returns

string | null

Inherited from

VirtualBase.toString


on()

on<K>(event: K, listener: Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>): Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

Starts listening to an event.

Type Parameters

K

K extends keyof VirtualFileEvents

Parameters

event

K

The event to listen to.

listener

Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

The function to call when the event is emitted.

Returns

Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

The listener.

Inherited from

VirtualBase.on


once()

once<K>(event: K, listener: Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>): Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

Registers an event listener that is automatically removed when called.

Type Parameters

K

K extends keyof VirtualFileEvents

Parameters

event

K

The event to listen to.

listener

Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

The function to call once the event is emitted.

Returns

Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

The wrapped listener.

Inherited from

VirtualBase.once


onAsync()

onAsync<K>(event: K, listener: AsyncListener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>, onRejected?: (reason: any) => unknown | null): Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

Starts listening to an event.

Type Parameters

K

K extends keyof VirtualFileEvents

Parameters

event

K

The event to listen to.

listener

AsyncListener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

The function to call when the event is emitted.

onRejected?

(reason: any) => unknown | null

Returns

Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

The wrapped listener.

Inherited from

VirtualBase.onAsync


off()

off<K>(event: K, listener: Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>): void

Removes an event listener.

Type Parameters

K

K extends keyof VirtualFileEvents

Parameters

event

K

The event to remove the listener from.

listener

Listener<VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>, K>

The listener to remove.

Returns

void

Inherited from

VirtualBase.off


emit()

emit<K>(event: K, ...args: VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>[K]): void

Emits an event to all its listeners.

Type Parameters

K

K extends keyof VirtualFileEvents

Parameters

event

K

The event to emit.

args

...VirtualFileEvents & Record<keyof VirtualFileEvents, unknown[]>[K]

The arguments to pass to the listeners.

Returns

void

Inherited from

VirtualBase.emit

Accessors

id

Get Signature

get id(): string

Returns

string

Overrides

VirtualBase.id


path

Get Signature

get path(): string

Returns the path of this item.

Returns

string

Inherited from

VirtualBase.path


displayPath

Get Signature

get displayPath(): string

Returns path without using this item's alias.

Returns

string

Inherited from

VirtualBase.displayPath


absolutePath

Get Signature

get absolutePath(): string

Returns path without using any aliases.

Returns

string

Inherited from

VirtualBase.absolutePath


canBeEdited

Get Signature

get canBeEdited(): boolean

Returns whether this can be edited in its current state.

Returns

boolean

Inherited from

VirtualBase.canBeEdited

Built by Prozilla