Skip to main content

read_file

Function read_file 

Source
pub fn read_file(path: &Path) -> Result<Vec<u8>>
Expand description

Reads a file, normalising all CR-only and CRLF line endings to LF.

Note for downstream consumers: the returned buffer never contains \r bytes. Callers that previously observed raw \r\n sequences will see plain \n after this call. This is intentional — the metric engine requires LF- only input — but it is a behavioural difference from a plain fs::read.

§Errors

Returns any std::io::Error surfaced by File::open (the path is missing, lacks read permission, is a directory, …) or by File::read_to_end while reading the file contents.

§Examples

use std::path::Path;

use big_code_analysis::read_file;

let path = Path::new("Cargo.toml");
read_file(&path).unwrap();