Skip to main content

classify

Function classify 

Source
pub fn classify(path: &Path) -> HookFile
Expand description

What is at path. Never mutates, never follows a link, never guesses.

The order of the tests is load-bearing:

  1. symlink_metadata — NOT metadata, which follows links and would report a symlink-to-a-shim as an ordinary file of ours. NotFound is the one error that means “nothing is there”; every other error means we could not look, which is HookFile::Unknown and refuses.
  2. symlink before file type, because a link to a regular file passes is_file() on a metadata call and would sail through.
  3. link count before reading, because a hard-linked file is foreign whatever its contents say.
  4. read, then UTF-8, then the marker — each failure its own named reason rather than a shared false.