bindet (binary file type detection)
Fast file type detection. Read more here: documentation
Supported file types
- Zip
- Rar (Rar 4 and 5)
- Tar
- Png
- Jpg
- 7-zip
- Opus
- Vorbis
- Mp3
- Webp
- Flac
- Matroska (mkv, mka, mks, mk3d, webm)
- Wasm
- Java Class
- Mach-O
- Elf (Executable and Linkable Format)
- Wav
- Avi
- Aiff
- Tiff
- Sqlite3 (
.db) - Ico
- Dalvik
- Gif
- Xcf
- Scala Tasty
- Bmp
- others are on the road
Example:
use ;
use BufReader;
use ErrorKind;
use bindet;
use FileType;
use FileTypeMatch;
use FileTypeMatches;
False Positives
Some file types magic numbers are composed of Human Readable Characters. For example, FLAC uses fLaC (0x66 0x4C 0x61 0x43)
and PDF uses %PDF- (0x25 0x50 0x44 0x46 0x2D), because of this, text files that starts with this sequence can be detected as a binary file.
bindet reports those file types with FileTypeMatch::full_match = false, a second step can take these types and validate
the prediction by applying a better specification match, however, at the moment, this only happens for Zip files.
You can use crates like encoding_rs to determine whether a file is really binary or text.