MCPcopy Create free account
hub / github.com/daisy/MathCAT / process_include

Function process_include

src/speech.rs:236–252  ·  view source on GitHub ↗
(current_file: &Path, new_file_name: &str, mut read_new_file: F)

Source from the content-addressed store, hash-verified

234}
235
236fn process_include<F>(current_file: &Path, new_file_name: &str, mut read_new_file: F) -> Result<()>
237 where F: FnMut(&Path) -> Result<()> {
238 let parent_path = current_file.parent();
239 if parent_path.is_none() {
240 bail!("Internal error: {:?} is not a valid file name", current_file);
241 }
242 let mut new_file = parent_path.unwrap().to_path_buf();
243 new_file.push(new_file_name);
244 info!("...processing include: {}...", new_file_name);
245 let new_file = match crate::shim_filesystem::canonicalize_shim(new_file.as_path()) {
246 Ok(buf) => buf,
247 Err(msg) => bail!("-include: constructed file name '{}' causes error '{}'",
248 new_file.to_str().unwrap(), msg),
249 };
250
251 return read_new_file(new_file.as_path());
252}
253
254/// As the name says, TreeOrString is either a Tree (Element) or a String
255/// It is used to share code during pattern matching

Callers 1

buildMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected