pub fn classify(path: &Path) -> HookFileExpand description
What is at path. Never mutates, never follows a link, never guesses.
The order of the tests is load-bearing:
symlink_metadata— NOTmetadata, which follows links and would report a symlink-to-a-shim as an ordinary file of ours.NotFoundis the one error that means “nothing is there”; every other error means we could not look, which isHookFile::Unknownand refuses.- symlink before file type, because a link to a regular file passes
is_file()on ametadatacall and would sail through. - link count before reading, because a hard-linked file is foreign whatever its contents say.
- read, then UTF-8, then the marker — each failure its own named reason
rather than a shared
false.