7 Workspaces
(require xiden/workspace) | package: xiden |
A workspace is a directory where Xiden performs all file I/O. That directory’s name is either xiden-workspace, or (file-name-from-path (getenv "XIDEN_WORKSPACE")) (See Selecting a Workspace). The path to a workspace is defined in workspace-directory, and must comply with workspace-directory/c.
A target workspace is the directory referenced by the value of (workspace-directory).
value
=
(and/c complete-path? (or/c directory-exists? (and/c (not/c file-exists?) (not/c directory-exists?) (not/c link-exists?))))
That is, a complete path that either refers to an existing directory, or a location on the filesystem where nothing exists.
If the directory does not exist, then it will be created when Xiden writes a file.
struct
(struct $invalid-workspace-envvar $message () #:prefab)
procedure
(build-workspace-path path-element) → complete-path?
path-element : (and/c path-string? (not/c complete-path?))
7.1 Selecting a Workspace
When Xiden starts, it selects a value to install in workspace-directory using the following rules.
The XIDEN_WORKSPACE environment variable is the only way to define a workspace with a non-conventional name.
If (workspace-directory/c W) is #f, then Xiden will print an error (but not halt) if W is set to a non-empty string.
If W was not used, then Xiden will walk towards a root directory starting from current-directory in search of an existing xiden-workspace. If one is found, then workspace-directory is set to its path.
If no directories were found in the walk towards a root directory, then workspace-directory is set to (build-path (current-directory) CONVENTIONAL_WORKSPACE_NAME).
7.2 State Management
(require xiden/localstate) | package: xiden |
7.2.1 Garbage Collection
struct
(struct $finished-collecting-garbage $message (bytes-recovered) #:prefab) bytes-recovered : exact-nonnegative-integer?
procedure
(xiden-collect-garbage) → exact-nonnegative-integer?
Returns the estimated number of bytes recovered from disk. This number is not fully accurate, because of inaccuracies from file-size, and the fact that empty directories and links are treated as negligibly small.