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

Filesystem

OS.js Virtual Filesystem

Constructor Summary

Public Constructor
public

Create new instance

Member Summary

Public Members
public
public
public
public

Method Summary

Public Methods
public

Performs a VFS request with simulated HTTP request

public

Destroys instance

public

async init(): Promise<boolean>

Initializes Filesystem

public

mime(filename: string): string

Gets MIME

public

async mount(mount: Mountpoint): Mountpoint

Mounts given mountpoint

public

Creates realpath VFS request

public

request(req: Request | object, res: Response | object): Promise<*>

Crates a VFS request

public

async unmount(mount: Mountpoint): Promise<boolean>

Unmounts given mountpoint

public

async watch(mountpoint: Mountpoint): Promise<undefined>

Set up a watch for given mountpoint

Private Methods
private

async _watch(mountpoint: Mountpoint, adapter: FilesystemAdapter): Promise<undefined>

Internal method for setting up watch for given mountpoint adapter

Public Constructors

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

Create new instance

Params:

NameTypeAttributeDescription
core Core

Core reference

options FilesystemOptions
  • optional

Instance options

Public Members

public adapters: FilesystemAdapterMap source

public core: Core source

public mountpoints: Mountpoint[] source

public options: FilesystemOptions source

Public Methods

public call(options: FilesystemCallOptions): Promise<*> source

Performs a VFS request with simulated HTTP request

Params:

NameTypeAttributeDescription
options FilesystemCallOptions

Request options

...args *

Arguments to pass to VFS method

Return:

Promise<*>

public async destroy(): Promise<undefined> source

Destroys instance

Return:

Promise<undefined>

public async init(): Promise<boolean> source

Initializes Filesystem

Return:

Promise<boolean>

public mime(filename: string): string source

Gets MIME

Params:

NameTypeAttributeDescription
filename string

Input filename or path

Return:

string

public async mount(mount: Mountpoint): Mountpoint source

Mounts given mountpoint

Params:

NameTypeAttributeDescription
mount Mountpoint

Mountpoint

Return:

Mountpoint

the mountpoint

public realpath(filename: string, user: AuthUserProfile): Promise<string> source

Creates realpath VFS request

Params:

NameTypeAttributeDescription
filename string

The path

user AuthUserProfile
  • optional

User session object

Return:

Promise<string>

public request(req: Request | object, res: Response | object): Promise<*> source

Crates a VFS request

Params:

NameTypeAttributeDescription
req Request | object

HTTP Request object

res Response | object
  • optional

HTTP Response object

Return:

Promise<*>

public async unmount(mount: Mountpoint): Promise<boolean> source

Unmounts given mountpoint

Params:

NameTypeAttributeDescription
mount Mountpoint

Mountpoint

Return:

Promise<boolean>

public async watch(mountpoint: Mountpoint): Promise<undefined> source

Set up a watch for given mountpoint

Params:

NameTypeAttributeDescription
mountpoint Mountpoint

The mountpoint

Return:

Promise<undefined>

Private Methods

private async _watch(mountpoint: Mountpoint, adapter: FilesystemAdapter): Promise<undefined> source

Internal method for setting up watch for given mountpoint adapter

Params:

NameTypeAttributeDescription
mountpoint Mountpoint

The mountpoint

adapter FilesystemAdapter

The adapter

Return:

Promise<undefined>