Expand description
File type detection: signature first, extension as a hint.
Order (see docs/PRD/03-tech-stack.md):
- magic bytes —
%PDF,{\rtf,PK\x03\x04(then peek inside the ZIP formimetype,word/,ppt/,xl/); - extension, which is what decides the text formats (txt/md/csv/…);
- a last-resort sniff for HTML in the head bytes.
Detection is a pure function over Sniff, so it is unit-testable without
touching the filesystem.
Structs§
- Sniff
- Everything detection needs about a file: its extension and its head bytes.
Enums§
- Format
- A document format DeepDoc knows about.
Constants§
- SNIFF_
LEN - How many bytes of the file head are read for sniffing.
Functions§
- detect
- Detect a format from already-sniffed bytes. Pure.
- detect_
path - Detect the format of a file on disk.
- detect_
signature - Detect a format from magic bytes alone.