Skip to main content

is_binary_file

Function is_binary_file 

Source
pub fn is_binary_file(path: &Path) -> bool
Expand description

Check if a file is binary using multiple heuristics

This function uses several techniques to detect binary files:

  1. File extension (known binary extensions)
  2. Null byte detection (most reliable for true binary files)
  3. Non-printable character ratio (for text files with some binary data)
  4. UTF-8 validity (text files should be valid UTF-8)