GlobalFsInterface

GlobalFsInterface

Interface for globals.fs. Applications are expected to implement each of the documented methods.

Methods

clean(path) → {undefined|Promise.<undefined>}

Source:
Parameters:
Name Type Description
path string

Path to a file on the local filesystem, as returned by get.

Returns:

Any resources used by get to return path can be freed. For example, if path refers to a temporary file, it can be removed. No value is returned, though the method may be asynchronous.

Type
undefined | Promise.<undefined>

exists(path) → {boolean|Promise.<boolean>}

Source:
Parameters:
Name Type Description
path string

Path to the file, see get for details.

Returns:

Whether the path exists.

Type
boolean | Promise.<boolean>

get(path, optionsopt) → {Uint8Array|string|Promise.<(Uint8Array|string)>}

Source:
Parameters:
Name Type Attributes Default Description
path string

Path to the file. This may be relative or absolute, depending on the application. The path may refer to a file not on the local filesystem, e.g., on a remote server, inside an archive file.

options object <optional>
{}

Further options.

Properties
Name Type Attributes Default Description
asBuffer boolean <optional>
false

Whether to return the file contents as a Uint8Array.

Returns:

Relative or absolute path to the file on the local filesystem. Callers should pass this path to clean once the file is no longer required.

If asBuffer = true or if no local filesystem is available, a Uint8Array of the file contents is returned instead. This does not need to be passed to clean.

A promise of a string or Uint8Array may also be returned.

Type
Uint8Array | string | Promise.<(Uint8Array|string)>

mkdir(path) → {undefined|Promise.<undefined>}

Source:
Parameters:
Name Type Description
path string

Path to a directory. This may be relative or absolute, depending on the application. As with get, the path may refer to a directory not on the local filesystem, e.g., on a remote server, inside an archive file. It is assumed that all parent directories have already been created.

Returns:

A new directory is created at path. (This may be a no-op if the application does not support creation of directories.) No value is returned, though the method may be asynchronous.

Type
undefined | Promise.<undefined>

write(path, contents) → {undefined|Promise.<undefined>}

Source:
Parameters:
Name Type Description
path string

Path to the file, see get for details.

contents Uint8Array

Contents of the file.

Returns:

contents is stored at path. The exact nature of this storage depends on the application - it may involve saving a file to the local filesystem, or uploading a file to a server, etc. If path already exists, it should be overwritten with contents. No value is returned, though the method may be asynchronous.

Type
undefined | Promise.<undefined>