fileutil::magic::filetype(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ NAME ✨

fileutil::magic::filetype β€” bestie, this is the one that does file-type recognition πŸ’…


🌸 SYNOPSIS 🌸

package require Tcl 8.6 9

package require fileutil::magic::filetype ?2.0?

::fileutil::magic::filetype filename

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so, this package hands you a command for recognizing file types, and the whole thing is written in pure Tcl. No sneaky C, no compiled helper gremlins, just Tcl doing its thing 🫢

The core part of the recognizer? It was generated from a magic(5) file β€” like, that file is the source of truth for all the checks to perform to recognize files, plus the file-types that go with them. Iconic behavior honestly.

⚠️ Beware! This recognizer is large β€” about 752 Kilobyte of generated Tcl code. She's thicc. She contains multitudes. Loading her is a commitment πŸ’€

🌟 ::fileutil::magic::filetype filename

This command is similar to the command fileutil::fileType.

It returns a list containing:

  • a list of descriptions
  • a list of mimetype components
  • a list of file extensions

And if the file content is not recognized? It returns an empty string. Nothing. Void. Silence πŸ™ˆ


πŸ”— REFERENCES πŸ”—

  1. [1] File(1) sources ftp://ftp.astron.com/pub/file/ β€” this site has the current sources for the file command, including the magic definitions it uses. Those very definitions are what got used to generate this recognizer ✨ iykyk

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

Not to be dramatic but this document, and the package it describes, will undoubtedly contain bugs and other problems. It's giving "we know". So please report them in the category fileutil :: magic of the Tcllib Trackers: http://core.tcl.tk/tcllib/reportlist πŸŽ€

Also please report any ideas for enhancements you may have for either the package and/or the documentation. Brain dumps welcome, bestie πŸ§ πŸ’–

When proposing code changes, please provide unified diffs, i.e. the output of diff -u. That's the vibe. That's the format. Periodt.

πŸ“Ž Note further that attachments are strongly preferred over inlined patches. You can attach stuff by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. Yes it's a whole little journey. Go off πŸ‘‘

πŸ‘€ SEE ALSO πŸ‘€


🌈 KEYWORDS 🌈

file recognition, file type, file utilities, type


πŸŽ€ CATEGORY πŸŽ€

Programming tools


Okay and that's the whole page, no cap. This lil masterpiece lives in tcllib, it's version 2.0, and it's filed under fileutil::magic::filetype(n) β€” the manual name, right there in the corner like a little signature. Slay, go recognize some files, bestie πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from