From: Ian Jackson Date: Mon, 7 Jun 2021 17:18:59 +0000 (+0100) Subject: bundles: Restructure zip load_spec_to_read X-Git-Tag: otter-0.7.0~43 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f100ffb3ca955a54462c987fba40c429fdac0140;p=otter.git bundles: Restructure zip load_spec_to_read Move more into the Zip branch to simplify the structure. Signed-off-by: Ian Jackson --- diff --git a/src/bundles.rs b/src/bundles.rs index 0afce323..9fd4477a 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -906,18 +906,21 @@ pub fn load_spec_to_read(ig: &Instance, spec_name: &str) -> String { let spec_leaf = format!("{}.game.toml", spec_name); if let Some((id, index)) = ig.bundle_specs.get(&UniCase::from(spec_name)) { - let fpath = id.path_(&ig.name); - let f = File::open(&fpath) - .with_context(|| fpath.clone()).context("reopen bundle") - .map_err(IE::from)?; match id.kind { Kind::Zip => { + + let fpath = id.path_(&ig.name); + let f = File::open(&fpath) + .with_context(|| fpath.clone()).context("reopen bundle") + .map_err(IE::from)?; + let mut za = ZipArchive::new(BufReader::new(f)).map_err( |e| LE::BadBundle(format!("re-examine zipfile: {}", e)))?; let mut f = za.i(*index).map_err( |e| LE::BadBundle(format!("re-find zipfile member: {}", e)))?; return read_from_read(&mut f, &mut |e|{ LE::BadBundle(format!("read zipfile member: {}", e))}.into())?; + } } }