Expand description
Path-spelling styles for the CLI and interactive shell.
Filesystem readers in this crate all speak one canonical path form:
components separated by /, and — for classic HFS and HFS+, whose on-disk
separator is : so a literal / is a legal filename character — any real
/ inside a name is stored swapped to :. (A real : can never appear in
an HFS/HFS+ name, so that swap is a bijection.)
Users, however, may want to spell paths the way the filesystem’s own OS did.
PathStyle selects between:
PathStyle::Unix(default) —/separates everywhere; an HFS/HFS+ name’s literal/shows as:(the convention macOS itself uses when surfacing HFS names to the BSD layer). Identical to the canonical form, so translation is a no-op.PathStyle::Native— the filesystem’s own separator::for HFS/HFS+,\for FAT/exFAT/NTFS,/for everything else. Real filenames are shown verbatim (an HFS name keeps its literal/). The root is a bare leading separator (:or\).
Translation lives here, at the CLI boundary, so the readers never need to
know which style the user picked: to_canonical turns user input into the
canonical form the readers consume, and display_name/display_path
turn canonical names/paths back into the chosen style for output.
Enums§
- Path
Style - How paths are spelled on the command line and in the shell.
Functions§
- display_
name - Translate a single canonical leaf name into display form for
style— used for each entry of anls. Only HFS/HFS+ underPathStyle::Nativechange: the canonical:(a swapped-in/) is shown as the real/. - display_
path - Translate a full canonical path into display form for
style— used forls -Rdirectory headers and the shell prompt.PathStyle::Unix(and/-native filesystems) pass through; native rejoins components with the native separator (prefixed, so the root is a bare separator) and reverses the HFS/HFS+ in-name:→/swap. - to_
canonical - Translate a user-supplied path (written in
style) into the canonical form the filesystem readers consume.