diff --git a/src/ioconverter.rs b/src/ioconverter.rs index 6dafcab2..d3eb2b5d 100644 --- a/src/ioconverter.rs +++ b/src/ioconverter.rs @@ -5,12 +5,11 @@ use std::cell::RefCell; pub struct IoConverter { inner: RefCell, - eofs: usize, } impl IoConverter { pub fn new(inner: T) -> IoConverter { - IoConverter { inner: RefCell::new(inner), eofs: 0, } + IoConverter { inner: RefCell::new(inner), } } pub fn into_inner(self) -> T { self.inner.into_inner() @@ -41,27 +40,7 @@ impl Write for IoConverter { } } -impl old_io::Seek for IoConverter { - fn tell(&self) -> old_io::IoResult { - match self.inner.borrow_mut().seek(io::SeekFrom::Current(0)) { - Ok(v) => Ok(v), - Err(..) => Err(old_io::standard_error(old_io::OtherIoError)), - } - } - fn seek(&mut self, pos: i64, style: old_io::SeekStyle) -> old_io::IoResult<()> { - let new_pos = match style { - old_io::SeekSet => io::SeekFrom::Start(pos as u64), - old_io::SeekEnd => io::SeekFrom::End(pos), - old_io::SeekCur => io::SeekFrom::Current(pos), - }; - match self.inner.borrow_mut().seek(new_pos) { - Ok(..) => Ok(()), - Err(..) => Err(old_io::standard_error(old_io::OtherIoError)), - } - } -} - -impl Read for IoConverter { +impl Read for IoConverter { fn read(&mut self, buf: &mut [u8]) -> io::Result { match self.inner.borrow_mut().read(buf) { Ok(v) => Ok(v), @@ -74,14 +53,7 @@ impl Read for IoConverter { impl Reader for IoConverter { fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult { match self.inner.borrow_mut().read(buf) { - Ok(0) => { - if self.eofs >= 2 { - Err(old_io::standard_error(old_io::EndOfFile)) - } else { - self.eofs += 1; - Ok(0) - } - }, + Ok(0) if buf.len() > 0 => Err(old_io::standard_error(old_io::EndOfFile)), Ok(v) => Ok(v), Err(..) => Err(old_io::standard_error(old_io::OtherIoError)), } diff --git a/src/util.rs b/src/util.rs index 03ec9686..a606d0b9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -63,14 +63,6 @@ impl<'a, R: Read> Read for RefMutReader<'a, R> } } -impl<'a, R: Reader> Reader for RefMutReader<'a, R> -{ - fn read(&mut self, buf: &mut [u8]) -> ::std::old_io::IoResult - { - self.inner.read(buf) - } -} - /// Additional integer write methods for a io::Read pub trait WriteIntExt { /// Write a u32 in little-endian mode @@ -110,16 +102,12 @@ pub trait ReadIntExt { fn fill_exact(reader: &mut R, buf: &mut [u8]) -> io::Result<()> { let mut idx = 0; - let mut tries = 0; while idx < buf.len() { match reader.read(&mut buf[idx..]) { Err(v) => return Err(v), + Ok(0) => return Err(io::Error::new(io::ErrorKind::ResourceUnavailable, "Could not fill the buffer", None)), Ok(i) => idx += i, } - tries += 1; - if tries > 2*buf.len() { - return Err(io::Error::new(io::ErrorKind::ResourceUnavailable, "Could not fill the buffer", None)); - } } Ok(()) } diff --git a/src/writer.rs b/src/writer.rs index 5bf2a4ad..03e265bd 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -7,7 +7,6 @@ use result::{ZipResult, ZipError}; use std::default::Default; use std::io; use std::io::prelude::*; -use std::old_io::Writer; use std::mem; use time; use flate2;