Skip to main content

Module globs

Module globs 

Source
Expand description

What type a file is, decided by its name.

The shared MIME database ships globs2, a plain list of weight:type:pattern lines that every desktop already agrees on. This reads it; it does not invent rules of its own.

§Why by name, and not by content

Content sniffing gets the interesting cases wrong in a way that is invisible until someone double-clicks. file --mime-type — which is what xdg-open falls back to on a desktop it does not recognise, Hyprland included — reads bytes and never the name, so a .stl is application/octet-stream, a .3mf is application/zip (it is one) and a .blend is application/zstd (it is that too). Those are all true statements about the bytes and useless statements about the file: nothing has a default application for them, and a lookup that finds nothing sends the file to a web browser.

The name knows. part.3mf is a 3MF model that happens to be stored as a zip, and that is exactly what globs2 says.

Content sniffing answers the cases a name cannot — a file with no extension at all — and lives in crate::magic. Which of the two wins, and when, is crate::lookup: a name beats a weak content guess, and a strong one beats a name.

Structs§

Globs
The filename rules, loaded from every globs2 on the system.