/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Zip utilities related to localization packaging.
usecrate::std::{fs::File, io::Read, path::Path}; use anyhow::{Context, Result}; use zip::read::{ArchiveOffset, Config as ZipConfig, ZipArchive};
/// A firefox archive file. pubtype Archive = ZipArchive<File>;
/// Read a zip file. pubfn read_zip(path: &Path) -> Result<Archive> {
ZipArchive::with_config(
ZipConfig { // The archive starts at the beginning of the file (it's a standard zip file, no // prefix data). // // Without this explicit offset, the default behavior will not work for omnijar files // (which have the central directory at the beginning of the file, rather than just // before the end of central directory maker).
archive_offset: ArchiveOffset::Known(0),
},
File::open(&path).with_context(|| format!("failed to open {}", path.display()))?,
)
.with_context(|| format!("failed to read zip archive in {}", path.display()))
}
/// Read a file from the given zip archive as a string. pubfn read_archive_file_as_string(archive: &mut Archive, path: &str) -> anyhow::Result<String> { letmut file = archive
.by_name(path)
.with_context(|| format!("failed to locate {path} in archive"))?; letmut data = String::new();
file.read_to_string(&mut data)
.with_context(|| format!("failed to read {path} from archive"))?;
Ok(data)
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-08-24)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.