archive
/
md-pdf-rs
Archived
1
Fork 0
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

22 lines
661 B
Rust
Raw Permalink 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-26 15:22:20 +01:00
use utils::result_override;
2017-07-20 09:14:48 +01:00
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-26 15:33:13 +01:00
let mut input_file = try!(result_override(
File::open(input_file_path),
format!("Failed to open input file {}.", input_file_path.display())
));
try!(result_override(
input_file.read_to_string(&mut input),
format!("Failed to read input file {}.", input_file_path.display())
));
2017-11-26 17:55:00 +00:00
input.push_str("\n\n");
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
}