This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
md-pdf-rs/src/input.rs

19 lines
627 B
Rust
Raw Normal View History

2017-07-20 09:14:48 +01:00
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
2017-07-21 19:25:39 +01:00
pub fn read_input_files(files: Vec<PathBuf>) -> Result<String, String> {
2017-07-20 09:14:48 +01:00
let mut input = String::new();
for input_file_path in files.iter() {
2017-07-21 19:25:39 +01:00
let input_file_result = File::open(input_file_path);
if input_file_result.is_err() {
return Err(format!("Failed to open input file {}.", input_file_path.display()));
}
if input_file_result.unwrap().read_to_string(&mut input).is_err() {
return Err(format!("Failed to read input file {}.", input_file_path.display()));
}
2017-07-20 09:14:48 +01:00
}
2017-07-21 19:25:39 +01:00
return Ok(input);
2017-07-20 09:14:48 +01:00
}