AbsolutePath

Represents an absolute file system path, independently of what (or whether anything at all) exists at that path in the file system at any given time. An absolute path always starts with a / character, and holds a normalized string representation. This normalization is strictly syntactic, and does not access the file system in any way.

AbsolutePath.swift:39
struct AbsolutePath

The absolute path string is normalized by:

  • Collapsing .. path components

  • Removing . path components

  • Removing any trailing path separator

  • Removing any redundant path separators

This string manipulation may change the meaning of a path if any of the path components are symbolic links on disk. However, the file system is never accessed in any way when initializing an AbsolutePath.

Note that ~ (home directory resolution) is not done as part of path normalization, because it is normally the responsibility of the shell and not the program being invoked (e.g. when invoking cd ~, it is the shell that evaluates the tilde; the cd command receives an absolute path).