Home Reference Source
import Filesystem from '@osjs/client/src/filesystem.js'
public class | source

Filesystem

Extends:

@osjs/event-emitter~EventEmitter → Filesystem

Filesystem Class that manages filesystems and adapters

Constructor Summary

Public Constructor
public

Create filesystem manager

Member Summary

Public Members
public

adapters: {name: FilesystemAdapterWrapper}

Adapter registry

public

Core instance reference

public

Mountpoints

public

Options

public

proxy: {key: Function}

A wrapper for VFS method requests

Method Summary

Public Methods
public

Adds a new mountpoint

public

Creates a new mountpoint based on given properties

public

Gets mountpoint from given path

public

Gets all mountpoints

public

Mount given mountpoint

public

mountAll(stopOnError: boolean): Promise<boolean[]>

Mounts all configured mountpoints

public

Gets the proxy for VFS methods FIXME: Not correct type, but works for documentation atm

public

Unmount given filesystem

Private Methods
private

Gets configured mountpoints

private

Internal wrapper for mounting/unmounting by name

private

Internal wrapper for mounting/unmounting

private

_request(method: string): *

Perform a VFS method request

private

Request action wrapper

Public Constructors

public constructor(core: Core, options: FilesystemOptions) source

Create filesystem manager

Params:

NameTypeAttributeDescription
core Core

Core reference

options FilesystemOptions
  • optional

Options

Public Members

public adapters: {name: FilesystemAdapterWrapper} source

Adapter registry

public core: Core source

Core instance reference

public mounts: FilesystemMountpoint[] source

Mountpoints

public options: FilesystemOptions source

Options

public proxy: {key: Function} source

A wrapper for VFS method requests

Public Methods

public addMountpoint(props: FilesystemMountpoint, automount: boolean): Promise<boolean> source

Adds a new mountpoint

Params:

NameTypeAttributeDescription
props FilesystemMountpoint

Mountpoint props

automount boolean
  • optional
  • default: true

Automount after creation

Return:

Promise<boolean>

public createMountpoint(props: FilesystemMountpoint): FilesystemMountpoint source

Creates a new mountpoint based on given properties

Params:

NameTypeAttributeDescription
props FilesystemMountpoint

Properties

public getMountpointFromPath(file: string | VFSFile): FilesystemMountpoint | null source

Gets mountpoint from given path

Params:

NameTypeAttributeDescription
file string | VFSFile

The file

public getMounts(all: boolean): FilesystemMountpoint[] source

Gets all mountpoints

Params:

NameTypeAttributeDescription
all boolean
  • optional
  • default: false

public mount(m: string | FilesystemMountpoint): Promise<boolean> source

Mount given mountpoint

Params:

NameTypeAttributeDescription
m string | FilesystemMountpoint

Mountpoint name or object

Return:

Promise<boolean>

Throw:

Error

On invalid name or if already mounted

public mountAll(stopOnError: boolean): Promise<boolean[]> source

Mounts all configured mountpoints

Params:

NameTypeAttributeDescription
stopOnError boolean
  • optional
  • default: true

Stop on first error

Return:

Promise<boolean[]>

public request(): FilesystemAdapterMethods source

Gets the proxy for VFS methods FIXME: Not correct type, but works for documentation atm

Return:

FilesystemAdapterMethods

A map of VFS functions

public unmount(name: string): Promise<boolean> source

Unmount given filesystem

Params:

NameTypeAttributeDescription
name string

Filesystem name

Return:

Promise<boolean>

Throw:

Error

On invalid name or if already unmounted

Private Methods

private _getConfiguredMountpoints(): FilesystemMountpoint[] source

Gets configured mountpoints

private _mountAction(name: string, unmount: boolean): Promise<boolean> source

Internal wrapper for mounting/unmounting by name

Params:

NameTypeAttributeDescription
name string

Mountpoint name

unmount boolean
  • optional
  • default: false

If action is unmounting

Return:

Promise<boolean>

private _mountpointAction(mountpoint: FilesystemMountpoint, unmount: boolean): Promise<boolean> source

Internal wrapper for mounting/unmounting

Params:

NameTypeAttributeDescription
mountpoint FilesystemMountpoint

The mountpoint

unmount boolean
  • optional
  • default: false

If action is unmounting

Return:

Promise<boolean>

private _request(method: string): * source

Perform a VFS method request

Params:

NameTypeAttributeDescription
method string

VFS method name

...args *

Arguments

Return:

*

private _requestAction(method: string): Promise<*> source

Request action wrapper

Params:

NameTypeAttributeDescription
method string
...args *

Arguments

Return:

Promise<*>