1use std::fs::File;
2use std::io::{BufRead, BufReader};
3use std::path::Path;
4
5use rsomics_common::{Result, RsomicsError};
6
7pub fn count(input: &Path) -> Result<u64> {
8 let file = File::open(input)
9 .map_err(|e| RsomicsError::InvalidInput(format!("{}: {e}", input.display())))?;
10 let reader = BufReader::new(file);
11 let mut n: u64 = 0;
12 for line in reader.lines() {
13 let line = line.map_err(RsomicsError::Io)?;
14 if !line.starts_with('#') && !line.is_empty() {
15 n += 1;
16 }
17 }
18 Ok(n)
19}