pub fn head(path: &Path) -> Option<Vec<u8>>Expand description
The first SNIFF_BYTES of a file, for content matching.
The one way to read a file for typing. Bounded on purpose: this is asked about files a person just pointed at, which can be a 40GB disk image on a slow mount, and no magic rule in the database reaches anywhere near that far in.
It exists as its own function because the bound was written once and
then bypassed three times: Lookup::of_file, Lookup::all_of_file
and the mimetype command each read the whole file instead, so
nothing a person actually double-clicked was bounded at all. An
800MB file cost 766MB of resident memory to answer “what is this”.
That is the failure the project’s own rule about testing the
resource rather than the result is named after, and the tests here
had asked only what type came back.