Skip to content

Class VirtualRoot ​

Source: virtualRoot.ts

A virtual folder that serves as the root folder.

Extends ​

Constructors ​

Constructor ​

new VirtualRoot(systemManager: SystemManager): VirtualRoot

Parameters ​

systemManager ​

SystemManager

Returns ​

VirtualRoot

Overrides ​

VirtualFolder.constructor

Properties ​

subFolders ​

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

The folders inside this folder.

Inherited from ​

VirtualFolder.subFolders


files ​

files: (VirtualFile | VirtualFileLink)[]

The files inside this folder.

Inherited from ​

VirtualFolder.files


type ​

type: number | undefined

The type of this folder.

Default ​

ts
VirtualFolder.TYPE.general

Inherited from ​

VirtualFolder.type


TYPE ​

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

general ​

general: number = 0

media ​

media: number = 1

Inherited from ​

VirtualFolder.TYPE


shortcuts ​

shortcuts: Record<string, VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink>

Aliases for files and folders.


initiated ​

initiated: boolean = false


loadedDefaultData ​

loadedDefaultData: boolean = false


systemManager ​

systemManager: SystemManager


storage ​

storage: VirtualDriveStorage


ERROR_EVENT ​

readonly static ERROR_EVENT: "error" = "error"


name ​

name: string

The name of this item.

Inherited from ​

VirtualFolder.name


alias ​

alias: string | null | undefined

The alias of this item.

Inherited from ​

VirtualFolder.alias


parent ​

parent: VirtualFolder<VirtualBaseEvents> | null | undefined

The folder this item is in.

Inherited from ​

VirtualFolder.parent


isProtected ​

isProtected: boolean | null | undefined

Whether this item is protected from changes.

Inherited from ​

VirtualFolder.isProtected


iconUrl ​

iconUrl: string | null | undefined

The URL of the icon of this item.

Inherited from ​

VirtualFolder.iconUrl


linkedFile ​

linkedFile: VirtualFile | null | undefined

The file this item links to.

Inherited from ​

VirtualFolder.linkedFile


linkedFolder ​

linkedFolder: VirtualFolder<VirtualBaseEvents> | null | undefined

The folder this item links to.

Inherited from ​

VirtualFolder.linkedFolder


editedByUser ​

editedByUser: boolean | null | undefined

Whether this item has been edited by the user.

Inherited from ​

VirtualFolder.editedByUser


isRoot ​

isRoot: boolean | null | undefined

Whether this item is the root folder.

Inherited from ​

VirtualFolder.isRoot


root ​

root: VirtualRoot | null | undefined

The root folder.

Inherited from ​

VirtualFolder.root


isDeleted ​

isDeleted: boolean

Whether this item has been deleted.

Inherited from ​

VirtualFolder.isDeleted


UPDATE_EVENT ​

readonly static UPDATE_EVENT: "update" = "update"

Inherited from ​

VirtualFolder.UPDATE_EVENT

Methods ​

setAlias() ​

setAlias(alias: string): this

Parameters ​

alias ​

string

Returns ​

this

Inherited from ​

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

Inherited from ​

VirtualFolder.hasFile


hasFolder() ​

hasFolder(name: string): boolean

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

Parameters ​

name ​

string

Returns ​

boolean

Inherited from ​

VirtualFolder.hasFolder


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

Inherited from ​

VirtualFolder.findFile


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

Inherited from ​

VirtualFolder.findSubFolder


addFile() ​

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

Parameters ​

file ​

VirtualFile

confirmChanges? ​

boolean = true

Returns ​

this

Inherited from ​

VirtualFolder.addFile


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

Inherited from ​

VirtualFolder.createFile


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

Inherited from ​

VirtualFolder.createFiles


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

Inherited from ​

VirtualFolder.createFileLink


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

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

Parameters ​

{ name: string; }[]

Returns ​

this

Inherited from ​

VirtualFolder.createFileLinks


addFolder() ​

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

Parameters ​

folder ​

VirtualFolder

confirmChanges? ​

boolean = true

Returns ​

this

Inherited from ​

VirtualFolder.addFolder


createFolder() ​

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

Creates a folder with a name.

Parameters ​

name ​

string

callback? ​

(newFolder: VirtualFolder) => void

Returns ​

this

Inherited from ​

VirtualFolder.createFolder


createFolders() ​

createFolders(names: string[]): this

Creates folders based on an array of folder names.

Parameters ​

names ​

string[]

Returns ​

this

Inherited from ​

VirtualFolder.createFolders


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

Inherited from ​

VirtualFolder.createFolderLink


createFolderLinks(names: string[]): this

Creates folder links based on an array of folder names.

Parameters ​

names ​

string[]

Returns ​

this

Inherited from ​

VirtualFolder.createFolderLinks


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

Inherited from ​

VirtualFolder.remove


create() ​

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

Parameters ​

relativePath ​

string

Returns ​

VirtualFolder<VirtualBaseEvents> | VirtualFile | null

Inherited from ​

VirtualFolder.create


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

Inherited from ​

VirtualFolder.navigate


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

Parameters ​

relativePath ​

string

Returns ​

VirtualFolder<VirtualBaseEvents> | null

Inherited from ​

VirtualFolder.navigateToFolder


navigateToFile(relativePath: string): VirtualFile | null

Parameters ​

relativePath ​

string

Returns ​

VirtualFile | null

Inherited from ​

VirtualFolder.navigateToFile


open() ​

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

Opens this folder in file explorer.

Parameters ​

windowsManager ​

WindowsManager

Returns ​

object | null | undefined

Inherited from ​

VirtualFolder.open


delete() ​

delete(): void

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

Returns ​

void

Inherited from ​

VirtualFolder.delete


getFiles() ​

getFiles(showHidden?: boolean): VirtualFile[]

Returns all files inside this folder.

Parameters ​

showHidden? ​

boolean = false

Whether to include hidden files.

Returns ​

VirtualFile[]

Inherited from ​

VirtualFolder.getFiles


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>[]

Inherited from ​

VirtualFolder.getSubFolders


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

Inherited from ​

VirtualFolder.getItemCount


isFolder() ​

isFolder(): this is VirtualFolder<VirtualBaseEvents>

Returns ​

this is VirtualFolder<VirtualBaseEvents>

Inherited from ​

VirtualFolder.isFolder


getIconUrl() ​

getIconUrl(): string

Returns ​

string

Inherited from ​

VirtualFolder.getIconUrl


loadDefaultData() ​

loadDefaultData(): void

Returns ​

void


loadData() ​

loadData(): void

Returns ​

void


saveData() ​

saveData(): void

Calls the storage manager's store function with this root's data as a string.

Returns ​

void


init() ​

init(): VirtualRoot

Initializes this root by loading the default data and then the user's data on top.

Returns ​

VirtualRoot


addShortcut() ​

addShortcut(name: string, destination: VirtualFolder<VirtualBaseEvents> | VirtualFile | VirtualFileLink | VirtualFolderLink): VirtualRoot

Adds a shortcut to a file or folder.

Parameters ​

name ​

string

destination ​

VirtualFolder<VirtualBaseEvents> | VirtualFile | VirtualFileLink | VirtualFolderLink

Returns ​

VirtualRoot


reset() ​

reset(): void

Tells the storage manager to clear all data and reloads the window.

Returns ​

void


isValidName() ​

static isValidName(_name: string): boolean

Parameters ​

_name ​

string

Returns ​

boolean


isValidFileName() ​

static isValidFileName(_name: string): boolean

Parameters ​

_name ​

string

Returns ​

boolean


isValidFolderName() ​

static isValidFolderName(_name: string): boolean

Parameters ​

_name ​

string

Returns ​

boolean


toJSON() ​

toJSON(): VirtualRootJson | null

Returns ​

VirtualRootJson | null

Overrides ​

VirtualFolder.toJSON


toString() ​

toString(): string | null

Returns a string representation of an object.

Returns ​

string | null

Overrides ​

VirtualFolder.toString


setName() ​

setName(name: string): this

Parameters ​

name ​

string

Returns ​

this

Inherited from ​

VirtualFolder.setName


setParent() ​

setParent(parent: VirtualFolder): this

Parameters ​

parent ​

VirtualFolder

Returns ​

this

Inherited from ​

VirtualFolder.setParent


setProtected() ​

setProtected(value: boolean): this

Parameters ​

value ​

boolean

Returns ​

this

Inherited from ​

VirtualFolder.setProtected


setIconUrl() ​

setIconUrl(iconUrl: string | null): this

Parameters ​

iconUrl ​

string | null

Returns ​

this

Inherited from ​

VirtualFolder.setIconUrl


getType() ​

getType(): string

Returns ​

string

Inherited from ​

VirtualFolder.getType


confirmChanges() ​

confirmChanges(root?: VirtualRoot): void

Parameters ​

root? ​

VirtualRoot

Returns ​

void

Inherited from ​

VirtualFolder.confirmChanges


getRoot() ​

getRoot(): VirtualRoot

Returns the root folder.

Returns ​

VirtualRoot

Inherited from ​

VirtualFolder.getRoot


isFile() ​

isFile(): this is VirtualFile

Returns ​

this is VirtualFile

Inherited from ​

VirtualFolder.isFile


isLink(): this is VirtualFileLink | VirtualFolderLink

Returns ​

this is VirtualFileLink | VirtualFolderLink

Inherited from ​

VirtualFolder.isLink


on() ​

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

Starts listening to an event.

Type Parameters ​

K ​

K extends keyof VirtualRootEvents

Parameters ​

event ​

K

The event to listen to.

listener ​

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

The function to call when the event is emitted.

Returns ​

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

The listener.

Inherited from ​

VirtualFolder.on


once() ​

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

Registers an event listener that is automatically removed when called.

Type Parameters ​

K ​

K extends keyof VirtualRootEvents

Parameters ​

event ​

K

The event to listen to.

listener ​

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

The function to call once the event is emitted.

Returns ​

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

The wrapped listener.

Inherited from ​

VirtualFolder.once


off() ​

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

Removes an event listener.

Type Parameters ​

K ​

K extends keyof VirtualRootEvents

Parameters ​

event ​

K

The event to remove the listener from.

listener ​

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

The listener to remove.

Returns ​

void

Inherited from ​

VirtualFolder.off


emit() ​

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

Emits an event to all its listeners.

Type Parameters ​

K ​

K extends keyof VirtualRootEvents

Parameters ​

event ​

K

The event to emit.

args ​

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

The arguments to pass to the listeners.

Returns ​

void

Inherited from ​

VirtualFolder.emit


emitAsync() ​

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

Emits an event and waits for all listeners to resolve.

Type Parameters ​

K ​

K extends keyof VirtualRootEvents

Parameters ​

event ​

K

The event to emit.

args ​

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

The arguments to pass to the listeners.

Returns ​

Promise<void>

Inherited from ​

VirtualFolder.emitAsync

Accessors ​

path ​

Get Signature ​

get path(): string

Returns the path of this item.

Returns ​

string

Overrides ​

VirtualFolder.path


displayPath ​

Get Signature ​

get displayPath(): string

Returns path without using this item's alias.

Returns ​

string

Overrides ​

VirtualFolder.displayPath


id ​

Get Signature ​

get id(): string

Returns ​

string

Inherited from ​

VirtualFolder.id


absolutePath ​

Get Signature ​

get absolutePath(): string

Returns path without using any aliases.

Returns ​

string

Inherited from ​

VirtualFolder.absolutePath


canBeEdited ​

Get Signature ​

get canBeEdited(): boolean

Returns whether this can be edited in its current state.

Returns ​

boolean

Inherited from ​

VirtualFolder.canBeEdited

Built by Prozilla