Class: files

uCentral. files

The files utility class manages non-uci file attachments which are produced during schema rendering.

Members

readonlybasedir

The base directory for file attachments.

Methods

add_anonymous(location, name, content){string}

Add an anonymous file attachment.

Stores the given content in a file with a random name derived from the given location pointer and name hint.

Name Type Description
location string

The current location within the state we're traversing

name string

The name hint

content *

The content to store

Returns:
Type Description
string Returns the generated random file path.

Add a named file attachment.

Stores the given content in a file at the given path. Expands the path relative to the basedir if it is not absolute.

Name Type Description
path string

The file path

content *

The content to store

Escape the given string.

Escape any slash and tilde characters in the given string to allow using it as part of a JSON pointer expression.

Name Type Description
s string

The string to escape

Returns:
Type Description
string The escaped string

Recursively create the parent directories of the given path.

Recursively creates the parent directory structure of the given path and places any error messages in the given logs array.

Name Type Description
logs array

The array to store log messages into

path string

The path to create directories for

Returns:
Type Description
boolean Returns true if the parent directories were successfully created or did already exist, returns false in case an error occurred.

Purge the file attachment storage.

Recursively deletes the file attachment storage and places any error messages in the given logs array.

Name Type Description
logs array

The array to store log messages into

Write the staged file attachement contents to the filesystem.

Writes the staged attachment contents that were gathered during state rendering to the file system and places any encountered errors into the logs array.

Name Type Description
logs array

The array to store error messages into

Returns:
Type Description
boolean Returns true if all attachments were written succefully, returns false if one or more attachments could not be written.