fileutil::magic::filetype(n)
β¨ 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]File(1) sourcesftp://ftp.astron.com/pub/file/β this site has the current sources for thefilecommand, 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
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms