On this page:
workspace-directory/  c
7.1 Selecting a Workspace
7.2 State Management
7.2.1 Garbage Collection

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).


workspace-directory/c : contract?

(and/c complete-path?
       (or/c directory-exists?
             (and/c (not/c file-exists?)
                    (not/c directory-exists?)
                    (not/c link-exists?))))
A contract for a valid workspace directory path.

That is, a complete path that either refers to an existing directory, or a location on the filesystem where nothing exists.

The directory in which Xiden reads and writes files.

If the directory does not exist, then it will be created when Xiden writes a file.

Bound to "xiden-workspace". Use the identifier instead of a hard-coded string to track changes in conventions.


(struct $invalid-workspace-envvar $message ()
A message indicating that (getenv "XIDEN_WORKSPACE") is not useable as a workspace path.


(build-workspace-path path-element)  complete-path?

  path-element : (and/c path-string? (not/c complete-path?))
Like build-path, but the base of the returned path is (workspace-directory).

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.

Let W be (getenv "XIDEN_WORKSPACE"). If (workspace-directory/c W) is #t, then workspace-directory is set to W.

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 $finished-collecting-garbage $message (bytes-recovered)
  bytes-recovered : exact-nonnegative-integer?
A message for reporting the number of bytes freed from disk using xiden-collect-garbage.


(xiden-collect-garbage)  exact-nonnegative-integer?

Deletes all records of links that do not actually exist on disk, and deleltes any installed files or directories in the target workspace with no referencing links.

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.