JobWorkspace

interface JobWorkspace

Local Scratch Workspace

Represents a handle on a local workspace and provides methods for operating on files and directories in that workspace.

Author

Elizabeth Paige Harper https://github.com/foxcapades

Since

1.0.0

Properties

Link copied to clipboard
abstract val path: Path

Absolute path to this workspace on the local filesystem.

Functions

Link copied to clipboard
abstract fun copy(fromPath: String, toPath: String): Path

Copies the file at the given fromPath to the given toPath.

Link copied to clipboard
abstract fun delete(path: String)

Deletes the file at the given path if such a file exists.

Link copied to clipboard
abstract fun mkdir(path: String): Path

Creates an empty directory at the given path.

Link copied to clipboard
abstract fun openReader(path: String): Reader

Opens a Reader over the contents of the file at the given path.

Link copied to clipboard
abstract fun openStream(path: String): InputStream

Opens an InputStream over the contents of the file at the given path.

Link copied to clipboard
abstract fun readAsJson(path: String): JsonNode

Reads the contents of the file at the given path as a JSON value and returns it.

Link copied to clipboard
abstract fun readAsString(path: String): String

Reads the contents of the file at the given path into a String and returns it.

Link copied to clipboard
abstract fun touch(path: String): Path

Creates an empty file in this workspace at the given path.

Link copied to clipboard
abstract fun write(path: String, data: JsonNode): Path

Writes the given JsonNode to the file at the given path.

abstract fun write(path: String, data: InputStream): Path

Writes the contents of the given stream to the file at the given path.

abstract fun write(path: String, data: Reader): Path

Writes the contents of the given reader to the file at the given path.

abstract fun write(path: String, consumer: Consumer<OutputStream>): Path

Opens an output stream to the given path and passes it to the consumer, which can write arbitrary data to the file, then closes the stream.

abstract fun write(path: String, data: String): Path

Writes the given string to the file at the given path.