26 lines
732 B
Rust
26 lines
732 B
Rust
use std::io::{BufReader, BufRead, Write};
|
|
use std::fs::{File};
|
|
use std::path::PathBuf;
|
|
|
|
pub fn has_files(full_path: PathBuf, file: &str, content: &str, test_id: String) -> bool
|
|
{
|
|
if !full_path.exists() {
|
|
println!("id: {}", test_id.clone());
|
|
eprintln!("File '{}' doesn't exists", file);
|
|
return false;
|
|
}
|
|
|
|
let f = File::open(full_path).unwrap();
|
|
for line in BufReader::new(f).lines(){
|
|
if let Ok(line) = line {
|
|
if line != content {
|
|
println!("id: {}", test_id);
|
|
eprintln!("File '{}' is not equal, {} != {}", file, line, content);
|
|
return false;
|
|
}
|
|
return line == content;
|
|
}
|
|
}
|
|
return true;
|
|
}
|