mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
handle zip files with __MACOSX folder
This commit is contained in:
parent
5e01154d24
commit
5f24ab45c2
1 changed files with 8 additions and 3 deletions
|
|
@ -13,13 +13,18 @@ impl LogFile {
|
|||
let mut file = File::open(path)?;
|
||||
if path.ends_with(".zip") {
|
||||
let mut zip = ZipArchive::new(file)?;
|
||||
if zip.len() > 1 {
|
||||
let files: Vec<_> = zip
|
||||
.file_names()
|
||||
.enumerate()
|
||||
.filter(|(_, name)| !name.starts_with("__MACOSX"))
|
||||
.collect();
|
||||
if files.len() > 1 {
|
||||
return Err(ReadError::MultipleFiles);
|
||||
} else if zip.is_empty() {
|
||||
} else if files.is_empty() {
|
||||
return Err(ReadError::NoFiles);
|
||||
}
|
||||
|
||||
let mut log = zip.by_index(0)?;
|
||||
let mut log = zip.by_index(files[0].0)?;
|
||||
let mut content = String::with_capacity(log.size() as usize);
|
||||
log.read_to_string(&mut content)?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue