From 078ba7eda08361c0baa7ae78649d20e3257f2128 Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Thu, 29 Jan 2015 11:00:30 +0100 Subject: [PATCH] io -> old_io --- src/crc32.rs | 8 ++++---- src/reader.rs | 8 ++++---- src/reader_spec.rs | 12 ++++++------ src/result.rs | 8 ++++---- src/spec.rs | 10 +++++----- src/util.rs | 4 ++-- src/writer.rs | 14 +++++++------- src/writer_spec.rs | 6 +++--- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/crc32.rs b/src/crc32.rs index d5468499..26e64037 100644 --- a/src/crc32.rs +++ b/src/crc32.rs @@ -1,6 +1,6 @@ //! Helper module to compute a CRC32 checksum -use std::io; +use std::old_io; static CRC32_TABLE : [u32; 256] = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, @@ -90,16 +90,16 @@ impl Crc32Reader impl Reader for Crc32Reader { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult { let count = match self.inner.read(buf) { Ok(n) => n, - Err(ref e) if e.kind == io::EndOfFile => + Err(ref e) if e.kind == old_io::EndOfFile => { return if self.check_matches() { Err(e.clone()) } - else { Err(io::IoError { kind: io::OtherIoError, desc: "Invalid checksum", detail: None, }) } + else { Err(old_io::IoError { kind: old_io::OtherIoError, desc: "Invalid checksum", detail: None, }) } }, Err(e) => return Err(e), }; diff --git a/src/reader.rs b/src/reader.rs index 02eb4896..de5f725c 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4,7 +4,7 @@ use compression::CompressionMethod; use spec; use reader_spec; use result::{ZipResult, ZipError}; -use std::io; +use std::old_io; use std::cell::RefCell; use std::collections::HashMap; use flate2::FlateReader; @@ -61,7 +61,7 @@ impl ZipReader let mut files = Vec::with_capacity(number_of_files); let mut names_map = HashMap::new(); - try!(reader.seek(directory_start, io::SeekSet)); + try!(reader.seek(directory_start, old_io::SeekSet)); for _ in (0 .. number_of_files) { let file = try!(reader_spec::central_header_to_zip_file(&mut reader)); @@ -101,9 +101,9 @@ impl ZipReader return unsupported_zip_error("Encrypted files are not supported") } - try!(inner_reader.seek(pos, io::SeekSet)); + try!(inner_reader.seek(pos, old_io::SeekSet)); let refmut_reader = ::util::RefMutReader::new(inner_reader); - let limit_reader = io::util::LimitReader::new(refmut_reader, file.compressed_size as usize); + let limit_reader = old_io::util::LimitReader::new(refmut_reader, file.compressed_size as usize); let reader = match file.compression_method { diff --git a/src/reader_spec.rs b/src/reader_spec.rs index bcee4d96..5e02f5bd 100644 --- a/src/reader_spec.rs +++ b/src/reader_spec.rs @@ -1,4 +1,4 @@ -use std::io; +use std::old_io; use std::num::FromPrimitive; use result::{ZipResult, ZipError}; use types::ZipFile; @@ -52,14 +52,14 @@ pub fn central_header_to_zip_file(reader: &mut R) -> ZipResult(reader: &mut R) -> ZipResult ZipResult<()> { - let mut reader = io::BufReader::new(data); + let mut reader = old_io::BufReader::new(data); while !reader.eof() { let kind = try!(reader.read_le_u16()); let len = try!(reader.read_le_u16()); match kind { - _ => try!(reader.seek(len as i64, io::SeekCur)), + _ => try!(reader.seek(len as i64, old_io::SeekCur)), } } Ok(()) diff --git a/src/result.rs b/src/result.rs index b271f566..ee94913a 100644 --- a/src/result.rs +++ b/src/result.rs @@ -1,6 +1,6 @@ //! Error types that can be emitted from this library -use std::io; +use std::old_io::IoError; use std::error; use std::fmt; @@ -12,7 +12,7 @@ pub type ZipResult = Result; pub enum ZipError { /// An Error caused by I/O - Io(io::IoError), + Io(IoError), /// This file is probably not a zipfile. The argument is enclosed. InvalidZipFile(&'static str), @@ -46,9 +46,9 @@ impl ZipError } } -impl error::FromError for ZipError +impl error::FromError for ZipError { - fn from_error(err: io::IoError) -> ZipError + fn from_error(err: IoError) -> ZipError { ZipError::Io(err) } diff --git a/src/spec.rs b/src/spec.rs index 4fce98ec..af4deaf5 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -1,4 +1,4 @@ -use std::io; +use std::old_io; use result::{ZipResult, ZipError}; use std::iter::range_step_inclusive; @@ -51,20 +51,20 @@ impl CentralDirectoryEnd { let header_size = 22; let bytes_between_magic_and_comment_size = header_size - 6; - try!(reader.seek(0, io::SeekEnd)); + try!(reader.seek(0, old_io::SeekEnd)); let file_length = try!(reader.tell()) as i64; let search_upper_bound = ::std::cmp::max(0, file_length - header_size - ::std::u16::MAX as i64); for pos in range_step_inclusive(file_length - header_size, search_upper_bound, -1) { - try!(reader.seek(pos, io::SeekSet)); + try!(reader.seek(pos, old_io::SeekSet)); if try!(reader.read_le_u32()) == CENTRAL_DIRECTORY_END_SIGNATURE { - try!(reader.seek(bytes_between_magic_and_comment_size, io::SeekCur)); + try!(reader.seek(bytes_between_magic_and_comment_size, old_io::SeekCur)); let comment_length = try!(reader.read_le_u16()) as i64; if file_length - pos - header_size == comment_length { - try!(reader.seek(pos, io::SeekSet)); + try!(reader.seek(pos, old_io::SeekSet)); return CentralDirectoryEnd::parse(reader); } } diff --git a/src/util.rs b/src/util.rs index fae5d8ee..5184ee77 100644 --- a/src/util.rs +++ b/src/util.rs @@ -24,7 +24,7 @@ pub fn msdos_datetime_to_tm(time: u16, date: u16) -> Tm { Ok(tm) => tm, Err(m) => { - let _ = write!(&mut ::std::io::stdio::stderr(), "Failed parsing date: {}", m); + let _ = write!(&mut ::std::old_io::stdio::stderr(), "Failed parsing date: {}", m); time::empty_tm() }, } @@ -55,7 +55,7 @@ impl<'a, R: Reader> RefMutReader<'a, R> impl<'a, R: Reader> Reader for RefMutReader<'a, R> { - fn read(&mut self, buf: &mut [u8]) -> ::std::io::IoResult + fn read(&mut self, buf: &mut [u8]) -> ::std::old_io::IoResult { self.inner.read(buf) } diff --git a/src/writer.rs b/src/writer.rs index cc6ae6c1..9e565c81 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -5,7 +5,7 @@ use writer_spec; use crc32; use result::{ZipResult, ZipError}; use std::default::Default; -use std::io; +use std::old_io; use std::mem; use time; use flate2; @@ -60,16 +60,16 @@ struct ZipWriterStats impl Writer for ZipWriter { - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> + fn write(&mut self, buf: &[u8]) -> old_io::IoResult<()> { - if self.files.len() == 0 { return Err(io::IoError { kind: io::OtherIoError, desc: "No file has been started", detail: None, }) } + if self.files.len() == 0 { return Err(old_io::IoError { kind: old_io::OtherIoError, desc: "No file has been started", detail: None, }) } self.stats.update(buf); match self.inner { GenericZipWriter::Storer(ref mut w) => w.write(buf), GenericZipWriter::Deflater(ref mut w) => w.write(buf), GenericZipWriter::Bzip2(ref mut w) => w.write(buf), - GenericZipWriter::Closed => Err(io::standard_error(io::Closed)), + GenericZipWriter::Closed => Err(old_io::standard_error(old_io::Closed)), } } } @@ -152,7 +152,7 @@ impl ZipWriter file.compressed_size = try!(writer.tell()) - self.stats.start; try!(writer_spec::update_local_file_header(writer, file)); - try!(writer.seek(0, io::SeekEnd)); + try!(writer.seek(0, old_io::SeekEnd)); Ok(()) } @@ -207,7 +207,7 @@ impl Drop for ZipWriter if !self.inner.is_closed() { if let Err(e) = self.finalize() { - let _ = write!(&mut ::std::io::stdio::stderr(), "ZipWriter drop failed: {:?}", e); + let _ = write!(&mut old_io::stdio::stderr(), "ZipWriter drop failed: {:?}", e); } } } @@ -222,7 +222,7 @@ impl GenericZipWriter GenericZipWriter::Storer(w) => w, GenericZipWriter::Deflater(w) => try!(w.finish()), GenericZipWriter::Bzip2(w) => match w.into_inner() { Ok(r) => r, Err((_, err)) => try!(Err(err)) }, - GenericZipWriter::Closed => try!(Err(io::standard_error(io::Closed))), + GenericZipWriter::Closed => try!(Err(old_io::standard_error(old_io::Closed))), }; *self = match compression diff --git a/src/writer_spec.rs b/src/writer_spec.rs index 236817f1..4cc9ebe5 100644 --- a/src/writer_spec.rs +++ b/src/writer_spec.rs @@ -1,4 +1,4 @@ -use std::io; +use std::old_io; use std::ascii::AsciiExt; use types::ZipFile; use result::ZipResult; @@ -29,7 +29,7 @@ pub fn write_local_file_header(writer: &mut T, file: &ZipFile) -> Zip pub fn update_local_file_header(writer: &mut T, file: &ZipFile) -> ZipResult<()> { static CRC32_OFFSET : i64 = 14; - try!(writer.seek(file.header_start as i64 + CRC32_OFFSET, io::SeekSet)); + try!(writer.seek(file.header_start as i64 + CRC32_OFFSET, old_io::SeekSet)); try!(writer.write_le_u32(file.crc32)); try!(writer.write_le_u32(file.compressed_size as u32)); try!(writer.write_le_u32(file.uncompressed_size as u32)); @@ -65,7 +65,7 @@ pub fn write_central_directory_header(writer: &mut T, file: &ZipFile) fn build_extra_field(_file: &ZipFile) -> ZipResult> { - let writer = io::MemWriter::new(); + let writer = old_io::MemWriter::new(); // Future work Ok(writer.into_inner()) }