diff --git a/src/reader/sync/decoder.rs b/src/reader/sync/decoder.rs index 4281bd8..fca6e56 100644 --- a/src/reader/sync/decoder.rs +++ b/src/reader/sync/decoder.rs @@ -98,43 +98,3 @@ impl io::Read for RawEntryReader { res } } - -/// Normalize EOF behavior for std::fs::File on Windows -/// (ie. makes it return Ok(0), not an OS-level I/O error) -/// Works for non-file Read impls, on non-Windows OSes too. -pub struct EOFNormalizer -where - R: io::Read, -{ - inner: R, -} - -impl EOFNormalizer -where - R: io::Read, -{ - pub fn new(inner: R) -> Self { - Self { inner } - } -} - -impl io::Read for EOFNormalizer -where - R: io::Read, -{ - #[inline] - fn read(&mut self, buf: &mut [u8]) -> io::Result { - #[cfg(windows)] - match self.inner.read(buf) { - Err(e) => match e.raw_os_error() { - // Windows error 38 = Reached end of file - Some(38) => Ok(0), - _ => Err(e), - }, - x => x, - } - - #[cfg(not(windows))] - self.inner.read(buf) - } -} diff --git a/src/reader/sync/entry_reader/mod.rs b/src/reader/sync/entry_reader/mod.rs index 7c1f448..5b17196 100644 --- a/src/reader/sync/entry_reader/mod.rs +++ b/src/reader/sync/entry_reader/mod.rs @@ -3,7 +3,7 @@ use crate::{ error::*, format::*, - reader::sync::decoder::{Decoder, EOFNormalizer, RawEntryReader, StoreDecoder}, + reader::sync::decoder::{Decoder, RawEntryReader, StoreDecoder}, transition, }; @@ -65,7 +65,7 @@ pub struct EntryReader where R: io::Read, { - rd: EOFNormalizer, + rd: R, eof: bool, state: State, inner: StoredEntryInner, @@ -260,7 +260,7 @@ where F: Fn(u64) -> R, { Self { - rd: EOFNormalizer::new(get_reader(entry.header_offset)), + rd: get_reader(entry.header_offset), eof: false, state: State::ReadLocalHeader { buffer: Buffer::with_capacity(Self::DEFAULT_BUFFER_SIZE),