Jido.VFS.RelativePath (Jido.VFS v1.0.0)

View Source

Utilities for validating and normalizing relative filesystem paths.

Summary

Functions

Ensures the given path represents a directory path ending in /.

Expands . path segments and rejects parent traversal beyond the root.

Joins a storage prefix with a normalized relative path, preserving a trailing slash.

Normalizes a relative path and rejects absolute or traversal paths.

Returns true when the given path is relative for Unix and Windows path formats.

Removes a prefix from a fully-qualified storage path.

Types

t()

@type t() :: Path.t()

Functions

assert_directory(path)

@spec assert_directory(Path.t()) :: {:ok, Path.t()} | {:error, :enotdir}

Ensures the given path represents a directory path ending in /.

expand(path)

@spec expand(t()) :: {:ok, t()} | {:error, term()}

Expands . path segments and rejects parent traversal beyond the root.

join_prefix(prefix, path)

@spec join_prefix(Path.t(), t()) :: Path.t()

Joins a storage prefix with a normalized relative path, preserving a trailing slash.

normalize(path)

@spec normalize(binary()) :: {:ok, t()} | {:error, term()}

Normalizes a relative path and rejects absolute or traversal paths.

relative?(path)

@spec relative?(binary()) :: boolean()

Returns true when the given path is relative for Unix and Windows path formats.

strip_prefix(prefix, path)

@spec strip_prefix(Path.t(), t()) :: Path.t()

Removes a prefix from a fully-qualified storage path.