Skip to content

Commit

Permalink
Improves readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecot committed Nov 7, 2023
1 parent 82e05ae commit 5190385
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/readers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,9 @@ impl crate::FileFormat {
reader.seek(SeekFrom::Start(offset))?;
let mut buffer = vec![0; std::cmp::min(END_OF_CENTRAL_DIRECTORY_MAX_SIZE, length as usize)];
reader.read_exact(&mut buffer)?;
if let Some(buffer_index) = find(&buffer, END_OF_CENTRAL_DIRECTORY_SIGNATURE) {
reader.seek(SeekFrom::Start(offset + buffer_index as u64))?;
} else {
return Err(Error::new(ErrorKind::InvalidData, "cannot find the EOCD"));
}
let buffer_index = find(&buffer, END_OF_CENTRAL_DIRECTORY_SIGNATURE)
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "cannot find the EOCD"))?;
reader.seek(SeekFrom::Start(offset + buffer_index as u64))?;

// Reads the start of central directory offset.
reader.seek(SeekFrom::Current(16))?;
Expand Down

0 comments on commit 5190385

Please sign in to comment.