3 ms·
Your doubts are incorrect. There's a fairly standard way of extracting the file type out of files on linux, which relies on a mix of extensions and magic bytes.
by scrollaway 1y ago
Your doubts are incorrect. There's a fairly standard way of extracting the file type out of files on linux, which relies on a mix of extensions and magic bytes. Here's where you can start to read about this:
https://wiki.archlinux.org/title/XDG_MIME_Applications https://wiki.archlinux.org/title/XDG_MIME_Applications
A lot of apps implement this (including most file managers)
- delusional 1y agoI'm a little surprised that that link doesn't go to libmagic[1]. No doubt XDG_MIME is an important spec for desktop file detection, but I think libmagic and the magic database that underpins it are more fundamental to filetype detection in general. It's also one of my favorite oddities on Linux. If you're a Windows user the idea of a database of signatures for filetypes that exists outside the application that "owns" a file type is novel and weird. [1]: https://man7.org/linux/man-pages/man3/libmagic.3.html https://man7.org/linux/man-pages/man3/libmagic.3.html
- scrollaway 1y agolibmagic maintains its own separate database from xdg. XDG db is meant from the ground up to have other apps add to it etc… so that one is the one apps use as a library usually, if they want to integrate nicely and correctly with other installed apps. libmagic is the hacking of the two :)