main: return list of region coordinates from process_region_dir()

This commit is contained in:
Matthias Schiffer 2023-03-01 19:16:09 +01:00
parent 194715ad09
commit ca6afa0cf9
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -102,7 +102,9 @@ impl RegionProcessor {
}
/// Iterates over all region files of a Minecraft save directory
fn process_region_dir(&self, regiondir: &Path) -> Result<()> {
///
/// Returns a list of the coordinates of all processed regions
fn process_region_dir(&self, regiondir: &Path) -> Result<Vec<RegionCoords>> {
let read_dir = regiondir
.read_dir()
.with_context(|| format!("Failed to read directory {}", regiondir.display()))?;
@ -114,6 +116,8 @@ impl RegionProcessor {
)
})?;
let mut ret = Vec::new();
for entry in read_dir.filter_map(|entry| entry.ok()).filter(|entry| {
// We are only interested in regular files
entry
@ -132,9 +136,11 @@ impl RegionProcessor {
coords.0, coords.1, err,
);
}
ret.push(coords);
}
Ok(())
Ok(ret)
}
}