Skip to content

Class VirtualFolder<E> ​

Source: virtualFolder.ts

A virtual folder that can contains files and sub-folders.

Extends ​

Extended by ​

Type Parameters ​

E ​

E extends VirtualBaseEvents = VirtualBaseEvents

Constructors ​

Constructor ​

new VirtualFolder<E>(name: string, type?: number): VirtualFolder<E>

Parameters ​

name ​

string

type? ​

number

Returns ​

VirtualFolder<E>

Overrides ​

VirtualBase.constructor

Properties ​

subFolders ​

subFolders: (VirtualFolder<VirtualBaseEvents> | VirtualFolderLink)[]

The folders inside this folder.


files ​

files: (VirtualFile | VirtualFileLink)[]

The files inside this folder.


type ​

type: number | undefined

The type of this folder.

Default ​

ts
VirtualFolder.TYPE.general

TYPE ​

static TYPE: { general: number; media: number; }

general ​

general: number = 0

media ​

media: number = 1


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


hasFile() ​

hasFile(name: string, extension?: string): boolean

Returns true if this folder contains a file matching a name and extension.

Parameters ​

name ​

string

extension? ​

string

Returns ​

boolean


hasFolder() ​

hasFolder(name: string): boolean

Returns true if this folder contains a folder matching a name.

Parameters ​

name ​

string

Returns ​

boolean


findFile() ​

findFile(name: string, extension?: string | null): VirtualFile | VirtualFileLink | null

Finds and returns a file inside this folder matching a name and extension.

Parameters ​

name ​

string

extension? ​

string | null

Returns ​

VirtualFile | VirtualFileLink | null


findSubFolder() ​

findSubFolder(name: string): VirtualFolder<VirtualBaseEvents> | VirtualFolderLink | null

Finds and returns a folder inside this folder matching a name.

Parameters ​

name ​

string

Returns ​

VirtualFolder<VirtualBaseEvents> | VirtualFolderLink | null


addFile() ​

addFile(file: VirtualFile, confirmChanges?: boolean): this

Parameters ​

file ​

VirtualFile

confirmChanges? ​

boolean = true

Returns ​

this


createFile() ​

createFile(name: string, extension?: string, callback?: (newFile: VirtualFile | VirtualFileLink) => void): this

Creates a file with a name and extension.

Parameters ​

name ​

string

extension? ​

string

callback? ​

(newFile: VirtualFile | VirtualFileLink) => void

Returns ​

this


createFiles() ​

createFiles(files: { name: string; extension: string; }[]): this

Creates files based on an array of objects with file names and extensions.

Parameters ​

files ​

{ name: string; extension: string; }[]

Returns ​

this


createFileLink(name: string, callback?: (newFileLink: VirtualFile | VirtualFileLink) => void): this

Creates a file link with a name.

Parameters ​

name ​

string

callback? ​

(newFileLink: VirtualFile | VirtualFileLink) => void

Returns ​

this


createFileLinks(fileLinks: { name: string; }[]): this

Creates file links based on an array of objects with file names and extensions.

Parameters ​

{ name: string; }[]

Returns ​

this


addFolder() ​

addFolder(folder: VirtualFolder, confirmChanges?: boolean): this

Parameters ​

folder ​

VirtualFolder

confirmChanges? ​

boolean = true

Returns ​

this


createFolder() ​

createFolder(name: string, callback?: (newFolder: VirtualFolder) => void): this

Creates a folder with a name.

Parameters ​

name ​

string

callback? ​

(newFolder: VirtualFolder) => void

Returns ​

this


createFolders() ​

createFolders(names: string[]): this

Creates folders based on an array of folder names.

Parameters ​

names ​

string[]

Returns ​

this


createFolderLink(name: string, callback?: (newFolderLink: VirtualFolder<VirtualBaseEvents> | VirtualFolderLink) => void): this

Creates a folder link with a name.

Parameters ​

name ​

string

callback? ​

(newFolderLink: VirtualFolder<VirtualBaseEvents> | VirtualFolderLink) => void

Returns ​

this


createFolderLinks(names: string[]): this

Creates folder links based on an array of folder names.

Parameters ​

names ​

string[]

Returns ​

this


remove() ​

remove(child: VirtualFolder<VirtualBaseEvents> | VirtualFile | VirtualFileLink | VirtualFolderLink): this

Removes a file or folder from this folder.

Parameters ​

child ​

VirtualFolder<VirtualBaseEvents> | VirtualFile | VirtualFileLink | VirtualFolderLink

Returns ​

this


create() ​

create(relativePath: string): VirtualFolder<VirtualBaseEvents> | VirtualFile | null

Parameters ​

relativePath ​

string

Returns ​

VirtualFolder<VirtualBaseEvents> | VirtualFile | null


navigate(relativePath: string, createIfMissing?: boolean): VirtualFolder<VirtualBaseEvents> | VirtualFile | null

Returns the file or folder at a relative path or null if it doesn't exist.

Parameters ​

relativePath ​

string

createIfMissing? ​

boolean = false

Returns ​

VirtualFolder<VirtualBaseEvents> | VirtualFile | null


navigateToFolder(relativePath: string): VirtualFolder<VirtualBaseEvents> | null

Parameters ​

relativePath ​

string

Returns ​

VirtualFolder<VirtualBaseEvents> | null


navigateToFile(relativePath: string): VirtualFile | null

Parameters ​

relativePath ​

string

Returns ​

VirtualFile | null


open() ​

open(windowsManager: WindowsManager): object | null | undefined

Opens this folder in file explorer.

Parameters ​

windowsManager ​

WindowsManager

Returns ​

object | null | undefined

Overrides ​

VirtualBase.open


delete() ​

delete(): void

Deletes this folder and all its files and sub-folders recursively.

Returns ​

void

Overrides ​

VirtualBase.delete


getFiles() ​

getFiles(showHidden?: boolean): VirtualFile[]

Returns all files inside this folder.

Parameters ​

showHidden? ​

boolean = false

Whether to include hidden files.

Returns ​

VirtualFile[]


getSubFolders() ​

getSubFolders(showHidden?: boolean): VirtualFolder<VirtualBaseEvents>[]

Returns all sub-folders inside this folder.

Parameters ​

showHidden? ​

boolean = false

Whether to include hidden folders.

Returns ​

VirtualFolder<VirtualBaseEvents>[]


getItemCount() ​

getItemCount(includeHidden?: boolean): number

Returns the amount of files and sub-folders inside this folder.

Parameters ​

includeHidden? ​

boolean = false

Whether to include hidden files and folders in the count.

Returns ​

number


isFolder() ​

isFolder(): this is VirtualFolder<VirtualBaseEvents>

Returns ​

this is VirtualFolder<VirtualBaseEvents>

Overrides ​

VirtualBase.isFolder


getIconUrl() ​

getIconUrl(): string

Returns ​

string

Overrides ​

VirtualBase.getIconUrl


toJSON() ​

toJSON(): VirtualFolderJson | null

Returns ​

VirtualFolderJson | null

Overrides ​

VirtualBase.toJSON


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


getType() ​

getType(): string

Returns ​

string

Inherited from ​

VirtualBase.getType


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


isFile() ​

isFile(): this is VirtualFile

Returns ​

this is VirtualFile

Inherited from ​

VirtualBase.isFile


isLink(): this is VirtualFileLink | VirtualFolderLink

Returns ​

this is VirtualFileLink | VirtualFolderLink

Inherited from ​

VirtualBase.isLink


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<E & Record<keyof E, unknown[]>, K>): Listener<E & Record<keyof E, unknown[]>, K>

Starts listening to an event.

Type Parameters ​

K ​

K extends string | number | symbol

Parameters ​

event ​

K

The event to listen to.

listener ​

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

The function to call when the event is emitted.

Returns ​

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

The listener.

Inherited from ​

VirtualBase.on


once() ​

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

Registers an event listener that is automatically removed when called.

Type Parameters ​

K ​

K extends string | number | symbol

Parameters ​

event ​

K

The event to listen to.

listener ​

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

The function to call once the event is emitted.

Returns ​

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

The wrapped listener.

Inherited from ​

VirtualBase.once


off() ​

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

Removes an event listener.

Type Parameters ​

K ​

K extends string | number | symbol

Parameters ​

event ​

K

The event to remove the listener from.

listener ​

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

The listener to remove.

Returns ​

void

Inherited from ​

VirtualBase.off


emit() ​

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

Emits an event to all its listeners.

Type Parameters ​

K ​

K extends string | number | symbol

Parameters ​

event ​

K

The event to emit.

args ​

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

The arguments to pass to the listeners.

Returns ​

void

Inherited from ​

VirtualBase.emit


emitAsync() ​

emitAsync<K>(event: K, ...args: E & Record<keyof E, unknown[]>[K]): Promise<void>

Emits an event and waits for all listeners to resolve.

Type Parameters ​

K ​

K extends string | number | symbol

Parameters ​

event ​

K

The event to emit.

args ​

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

The arguments to pass to the listeners.

Returns ​

Promise<void>

Inherited from ​

VirtualBase.emitAsync

Accessors ​

id ​

Get Signature ​

get id(): string

Returns ​

string

Inherited from ​

VirtualBase.id


path ​

Get Signature ​

get path(): string

Returns the path of this item.

Returns ​

string

Inherited from ​

VirtualFolderLink.path


displayPath ​

Get Signature ​

get displayPath(): string

Returns path without using this item's alias.

Returns ​

string

Inherited from ​

VirtualFolderLink.displayPath


absolutePath ​

Get Signature ​

get absolutePath(): string

Returns path without using any aliases.

Returns ​

string

Inherited from ​

VirtualFolderLink.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