SHTK_FS_NORMALIZE_PATH(3)

πŸ“¦ version 1.7, in nixos 26.05, nixpkgs unstable

🌸 NAME 🌸

Hiiii bestie πŸ’– this is SHTK_FS_NORMALIZE_PATH(3), a page straight out of the Library Functions Manual, and it's here to explain shtk_fs_normalize_path β€” the function that Returns a normalized form of a path. Slay. ✨

πŸŽ€ LIBRARY πŸŽ€

You import it with:

shtk_import fs

⭐ SYNOPSIS ⭐

shtk_fs_normalize_path path

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so shtk_fs_normalize_path takes the given path and prints its normalized form to stdout. That's the whole vibe. πŸ’…

This process involves the following:

  • Collapsing multiple consecutive forward slashes into one.
  • Adding a . component at the beginning of the path if it is relative.
  • Removing any . components, except for the first one.
  • Removing any trailing slashes.
No cap, important caveat: the normalization happens without performing any file system operations. Therefore, it is perfectly possible for two normalized paths that look different to point to the same file system entry. In particular, this is because normalization does not take into account links nor .. components. πŸ’€

πŸ’… RETURN VALUES πŸ’…

shtk_fs_normalize_path returns 0. Periodt. 🫢

πŸ”₯ EXAMPLES πŸ”₯

These little glow-ups are everything:

shtk_fs_normalize_path /foo/bar  # Prints /foo/bar
shtk_fs_normalize_path foo/bar  # Prints ./foo/bar
shtk_fs_normalize_path foo///bar/./baz//  # Prints ./foo/bar/baz

🌈 SEE ALSO 🌈

shtk(3), shtk_fs(3) β€” go read those too, bestie πŸ“š

πŸ‘‘ HISTORY πŸ‘‘

shtk_fs_normalize_path first appeared in shtk 1.7. Iconic behavior since day one πŸ’–


Source/version + date sign-off: this page is from Debian, dated September 18, 2016 β€” mwah, kisses πŸ’‹πŸ’…

πŸ“¦ where this page comes from