in tough/src/editor/signed.rs [588:635]
fn targets(&self) -> HashMap<TargetName, &Target>;
/// Determines whether or not consistent snapshot filenames should be used
fn consistent_snapshot(&self) -> bool;
/// Walks a given directory and calls the provided function with every file found.
/// The function is given the file path, the output directory where the user expects
/// it to go, and optionally a desired filename.
fn walk_targets<F>(
&self,
indir: &Path,
outdir: &Path,
f: F,
replace_behavior: PathExists,
) -> Result<()>
where
F: Fn(&Self, &Path, &Path, PathExists, Option<&TargetName>) -> Result<()>,
{
std::fs::create_dir_all(outdir).context(error::DirCreateSnafu { path: outdir })?;
// Get the absolute path of the indir and outdir
let abs_indir =
std::fs::canonicalize(indir).context(error::AbsolutePathSnafu { path: indir })?;
// Walk the absolute path of the indir. Using the absolute path here
// means that `entry.path()` call will return its absolute path.
let walker = WalkDir::new(&abs_indir).follow_links(true);
for entry in walker {
let entry = entry.context(error::WalkDirSnafu {
directory: &abs_indir,
})?;
// If the entry is not a file, move on
if !entry.file_type().is_file() {
continue;
};
// Call the requested function to manipulate the path we found
if let Err(e) = f(self, entry.path(), outdir, replace_behavior, None) {
match e {
// If we found a path that isn't a known target in the repo, skip it.
error::Error::PathIsNotTarget { .. } => continue,
_ => return Err(e),
}
}
}
Ok(())
}