Skip to content

Class VirtualFolder

Source: virtualFolder.ts

A virtual folder that can contains files and sub-folders

Extends

  • VirtualBase

Extended by

Accessors

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


displayPath

Get Signature

get displayPath(): string

Returns path without using this item's alias

Returns

string

Inherited from

VirtualBase.displayPath


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

VirtualBase.path

Constructors

Constructor

new VirtualFolder(name: string, type?: number): VirtualFolder

Parameters

name

string

type?

number

Returns

VirtualFolder

Overrides

VirtualBase.constructor

Methods

confirmChanges()

confirmChanges(root?: VirtualRoot): void

Parameters

root?

VirtualRoot

Returns

void

Inherited from

VirtualBase.confirmChanges


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


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


createFiles()

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

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

Parameters

files

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

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


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

Creates a folder link with a name

Parameters

name

string

callback?

(newFolderLink: VirtualFolder | VirtualFolderLink) => void

Returns

this


createFolderLinks(names: string[]): this

Creates folder links based on an array of folder names

Parameters

names

string[]

Returns

this


createFolders()

createFolders(names: string[]): this

Creates folders based on an array of folder names

Parameters

names

string[]

Returns

this


delete()

delete(): void

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

Returns

void

Overrides

VirtualBase.delete


emit()

emit<Key>(eventName: Key, data?: unknown): void

Dispatch event

Type Parameters

Key

Key extends string

Parameters

eventName

Key

data?

unknown

Returns

void

Inherited from

VirtualBase.emit


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

Finds and returns a folder inside this folder matching a name

Parameters

name

string

Returns

VirtualFolder | VirtualFolderLink | null


getFiles()

getFiles(showHidden: boolean): VirtualFile[]

Returns all files inside this folder

Parameters

showHidden

boolean = false

Whether to include hidden files

Returns

VirtualFile[]


getIconUrl()

getIconUrl(): string

Returns

string

Overrides

VirtualBase.getIconUrl


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


getRoot()

getRoot(): VirtualRoot

Returns the root folder

Returns

VirtualRoot

Inherited from

VirtualBase.getRoot


getSubFolders()

getSubFolders(showHidden: boolean): VirtualFolder[]

Returns all sub-folders inside this folder

Parameters

showHidden

boolean = false

Whether to include hidden folders

Returns

VirtualFolder[]


getType()

getType(): string

Returns

string

Inherited from

VirtualBase.getType


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


isFile()

isFile(): boolean

Returns

boolean

Inherited from

VirtualBase.isFile


isFolder()

isFolder(): boolean

Returns

boolean

Overrides

VirtualBase.isFolder


navigate(relativePath: string): VirtualFolder | VirtualFile | null

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

Parameters

relativePath

string

Returns

VirtualFolder | VirtualFile | null


off()

off<Key>(eventName: Key, callback: Listener): void

Remove event listener for an event

Type Parameters

Key

Key extends string

Parameters

eventName

Key

callback

Listener

Returns

void

Inherited from

VirtualBase.off


on()

on<Key>(eventName: Key, callback: Listener): Listener

Add event listener for an event

Type Parameters

Key

Key extends string

Parameters

eventName

Key

callback

Listener

Returns

Listener

Inherited from

VirtualBase.on


open()

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

Opens this folder in file explorer

Parameters

windowsManager

WindowsManager

Returns

object | null | undefined

Overrides

VirtualBase.open


remove()

remove(child: VirtualFolder | VirtualFile | VirtualFileLink | VirtualFolderLink): this

Removes a file or folder from this folder

Parameters

child

VirtualFolder | VirtualFile | VirtualFileLink | VirtualFolderLink

Returns

this


setAlias()

setAlias(alias: string): this

Parameters

alias

string

Returns

this

Overrides

VirtualBase.setAlias


setIconUrl()

setIconUrl(iconUrl: string | null): this

Parameters

iconUrl

string | null

Returns

this

Inherited from

VirtualBase.setIconUrl


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


toJSON()

toJSON(): VirtualFolderJson | null

Returns

VirtualFolderJson | null

Overrides

VirtualBase.toJSON


toString()

toString(): string | null

Returns a string representation of an object.

Returns

string | null

Inherited from

VirtualBase.toString

Properties

alias

alias: string | null | undefined

The alias of this item

Inherited from

VirtualBase.alias


editedByUser

editedByUser: boolean | null | undefined

Whether this item has been edited by the user

Inherited from

VirtualBase.editedByUser


EVENT_NAMES

static EVENT_NAMES: { update: string; }

update

update: string = "update"

Inherited from

VirtualBase.EVENT_NAMES


files

files: (VirtualFile | VirtualFileLink)[]

The files inside this folder


iconUrl

iconUrl: string | null | undefined

The URL of the icon of this item

Inherited from

VirtualBase.iconUrl


isDeleted

isDeleted: boolean

Whether this item has been deleted

Inherited from

VirtualBase.isDeleted


isProtected

isProtected: boolean | null | undefined

Whether this item is protected from changes

Inherited from

VirtualBase.isProtected


isRoot

isRoot: boolean | null | undefined

Whether this item is the root folder

Inherited from

VirtualBase.isRoot


linkedFile

linkedFile: VirtualFile | null | undefined

The file this item links to

Inherited from

VirtualBase.linkedFile


linkedFolder

linkedFolder: VirtualFolder | null | undefined

The folder this item links to

Inherited from

VirtualBase.linkedFolder


name

name: string

The name of this item

Inherited from

VirtualBase.name


parent

parent: VirtualFolder | null | undefined

The folder this item is in

Inherited from

VirtualBase.parent


root

root: VirtualRoot | null | undefined

The root folder

Inherited from

VirtualBase.root


subFolders

subFolders: (VirtualFolder | VirtualFolderLink)[]

The folders 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

Built by Prozilla