write -> write_all

This commit is contained in:
Mathijs van de Nes 2015-01-29 11:01:57 +01:00
parent 078ba7eda0
commit fc20f9a20c
3 changed files with 9 additions and 9 deletions

View file

@ -82,7 +82,7 @@ impl CentralDirectoryEnd
try!(writer.write_le_u32(self.central_directory_size)); try!(writer.write_le_u32(self.central_directory_size));
try!(writer.write_le_u32(self.central_directory_offset)); try!(writer.write_le_u32(self.central_directory_offset));
try!(writer.write_le_u16(self.zip_file_comment.len() as u16)); try!(writer.write_le_u16(self.zip_file_comment.len() as u16));
try!(writer.write(self.zip_file_comment.as_slice())); try!(writer.write_all(self.zip_file_comment.as_slice()));
Ok(()) Ok(())
} }
} }

View file

@ -60,15 +60,15 @@ struct ZipWriterStats
impl<W: Writer+Seek> Writer for ZipWriter<W> impl<W: Writer+Seek> Writer for ZipWriter<W>
{ {
fn write(&mut self, buf: &[u8]) -> old_io::IoResult<()> fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()>
{ {
if self.files.len() == 0 { return Err(old_io::IoError { kind: old_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); self.stats.update(buf);
match self.inner match self.inner
{ {
GenericZipWriter::Storer(ref mut w) => w.write(buf), GenericZipWriter::Storer(ref mut w) => w.write_all(buf),
GenericZipWriter::Deflater(ref mut w) => w.write(buf), GenericZipWriter::Deflater(ref mut w) => w.write_all(buf),
GenericZipWriter::Bzip2(ref mut w) => w.write(buf), GenericZipWriter::Bzip2(ref mut w) => w.write_all(buf),
GenericZipWriter::Closed => Err(old_io::standard_error(old_io::Closed)), GenericZipWriter::Closed => Err(old_io::standard_error(old_io::Closed)),
} }
} }

View file

@ -20,8 +20,8 @@ pub fn write_local_file_header<T: Writer>(writer: &mut T, file: &ZipFile) -> Zip
try!(writer.write_le_u16(file.file_name.as_bytes().len() as u16)); try!(writer.write_le_u16(file.file_name.as_bytes().len() as u16));
let extra_field = try!(build_extra_field(file)); let extra_field = try!(build_extra_field(file));
try!(writer.write_le_u16(extra_field.len() as u16)); try!(writer.write_le_u16(extra_field.len() as u16));
try!(writer.write(file.file_name.as_bytes())); try!(writer.write_all(file.file_name.as_bytes()));
try!(writer.write(extra_field.as_slice())); try!(writer.write_all(extra_field.as_slice()));
Ok(()) Ok(())
} }
@ -57,8 +57,8 @@ pub fn write_central_directory_header<T: Writer>(writer: &mut T, file: &ZipFile)
try!(writer.write_le_u16(0)); try!(writer.write_le_u16(0));
try!(writer.write_le_u32(0)); try!(writer.write_le_u32(0));
try!(writer.write_le_u32(file.header_start as u32)); try!(writer.write_le_u32(file.header_start as u32));
try!(writer.write(file.file_name.as_bytes())); try!(writer.write_all(file.file_name.as_bytes()));
try!(writer.write(extra_field.as_slice())); try!(writer.write_all(extra_field.as_slice()));
Ok(()) Ok(())
} }