IF Commons GitHub

governance/posix-path

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-posix-governance FR-004

The paths a program of POSIX gives, and how they become the keys of a store. A POSIX path is text: absolute from the root of the store, or relative to a working directory the program holds as a value (there is none in the process). . and .. are resolved by the text alone, and .. at the root stays at the root, as a file system does. A backslash, a control character and a NUL are refused at this boundary, never passed on. The key of a store is made from the resolved path by the parser of the store, so that nothing here can name what a store would refuse.

import { resolvePosix, ROOT_PATH } from "./posix-path.ts";
const r = resolvePosix(ROOT_PATH, "a//b/./c/../d");
r.kind === "ok" && r.value; // "/a/b/d"

Source: commons/anyfs-posix/src/governance/posix-path.ts

12 of 24 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

governance.PosixPathtypeno test imports it
type PosixPath = Brand<string, "anyfs posix path">;

An absolute path in the view of a store: /, or / and segments joined by /. Made only by resolvePosix and parseAbsolute.

governance.ROOT_PATHconstno test imports it
const ROOT_PATH: PosixPath

The root.

governance.resolvePosixfunctionno test imports it
function resolvePosix(cwd: PosixPath, text: string): Result<PosixPath, string>

A path from text, resolved against a working directory: absolute where it begins with /, otherwise below the working directory.

governance.parseAbsolutefunctionno test imports it
function parseAbsolute(text: string): Result<PosixPath, string>

An absolute path from text: the text begins with /.

governance.storePathOffunctionno test imports it
function storePathOf(path: PosixPath): Result<Path | undefined, string>

The key of a store for a path: nothing for the root, and the reason where the store would not take the path.

governance.prefixOffunctionno test imports it
function prefixOf(path: PosixPath): Result<Prefix, string>

The prefix of a store for a path: the root for the root.

governance.posixOffunctionno test imports it
function posixOf(path: Path): PosixPath

The path of a key of a store.

governance.parentPosixfunctionno test imports it
function parentPosix(path: PosixPath): PosixPath

The directory that holds a path: the root holds itself.

governance.baseNamefunctionno test imports it
function baseName(path: PosixPath): string | undefined

The last name of a path: nothing for the root.

governance.joinPosixfunctionno test imports it
function joinPosix(dir: PosixPath, name: string): PosixPath

The path of a name in a directory.

governance.isBelowfunctionno test imports it
function isBelow(dir: PosixPath, path: PosixPath): boolean

Whether a path is below a directory: the root holds every other path, and a path is not below itself.

governance.ancestorsOffunctionno test imports it
function ancestorsOf(path: PosixPath): readonly PosixPath[]

Every directory above a path, from the root's child down to its parent: none for the root and for a path of one name.

PosixPathtype
type PosixPath = Brand<string, "anyfs posix path">;

An absolute path in the view of a store: /, or / and segments joined by /. Made only by resolvePosix and parseAbsolute.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

ROOT_PATHconst
const ROOT_PATH: PosixPath

The root.

Imported by 15 tests of the run (15 passed, 0 failed): the library's results

resolvePosixfunction
function resolvePosix(cwd: PosixPath, text: string): Result<PosixPath, string>

A path from text, resolved against a working directory: absolute where it begins with /, otherwise below the working directory.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

parseAbsolutefunction
function parseAbsolute(text: string): Result<PosixPath, string>

An absolute path from text: the text begins with /.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

storePathOffunction
function storePathOf(path: PosixPath): Result<Path | undefined, string>

The key of a store for a path: nothing for the root, and the reason where the store would not take the path.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

prefixOffunction
function prefixOf(path: PosixPath): Result<Prefix, string>

The prefix of a store for a path: the root for the root.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

posixOffunction
function posixOf(path: Path): PosixPath

The path of a key of a store.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

parentPosixfunction
function parentPosix(path: PosixPath): PosixPath

The directory that holds a path: the root holds itself.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

baseNamefunction
function baseName(path: PosixPath): string | undefined

The last name of a path: nothing for the root.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

joinPosixfunction
function joinPosix(dir: PosixPath, name: string): PosixPath

The path of a name in a directory.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

isBelowfunction
function isBelow(dir: PosixPath, path: PosixPath): boolean

Whether a path is below a directory: the root holds every other path, and a path is not below itself.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

ancestorsOffunction
function ancestorsOf(path: PosixPath): readonly PosixPath[]

Every directory above a path, from the root's child down to its parent: none for the root and for a path of one name.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.