Expand description
Shared I/O helpers for content-reading rules.
Enums§
- Classification
- Classification of a file’s contents. Computed lazily — callers check the subset they care about.
Constants§
- TEXT_
INSPECT_ LEN - How much of a file to sample when classifying text vs. binary.
Functions§
- classify_
bytes - read_
prefix - Read up to
TEXT_INSPECT_LENbytes from the start of a file. ReturnedOk(None)means the file was empty;Erris propagated I/O error. - read_
prefix_ n - Read up to
nbytes from the start ofpath. Used by rules that only need to inspect a leading window —executable_has_shebang(2 bytes for#!),file_starts_with(pattern.len()bytes). Reads less thannif the file is shorter; returns the actual byte count in the returnedVec’s length. - read_
suffix_ n - Read up to
nbytes from the END ofpath. Used by rules that only need to inspect the tail —file_ends_with(pattern.len()bytes). Returns the actual byte count in the returnedVec’s length; fewer thannbytes if the file is shorter. Files smaller thannare read whole.