Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for the recently added `read_exact` method to `Read`. #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+10 −5
Diff settings

Always

Just for now

Copy path View file
@@ -1,6 +1,7 @@
//! A basic ZipReader/Writer crate

#![warn(missing_docs)]
#![feature(read_exact)]

extern crate bzip2;
extern crate flate2;
Copy path View file
@@ -195,9 +195,12 @@ fn central_header_to_zip_file<R: Read+io::Seek>(reader: &mut R) -> ZipResult<Zip
try!(reader.read_u16::<LittleEndian>());
try!(reader.read_u32::<LittleEndian>());
let offset = try!(reader.read_u32::<LittleEndian>()) as u64;
let file_name_raw = try!(reader.read_exact(file_name_length));
let extra_field = try!(reader.read_exact(extra_field_length));
let file_comment_raw = try!(reader.read_exact(file_comment_length));
let mut file_name_raw = vec![0; file_name_length];
try!(reader.read_exact(&mut file_name_raw));
let mut extra_field = vec![0; extra_field_length];
try!(reader.read_exact(&mut extra_field));
let mut file_comment_raw = vec![0; file_comment_length];
try!(reader.read_exact(&mut file_comment_raw));

let file_name = match is_utf8
{
@@ -206,7 +209,7 @@ fn central_header_to_zip_file<R: Read+io::Seek>(reader: &mut R) -> ZipResult<Zip
};
let file_comment = match is_utf8
{
true => String::from_utf8_lossy(&*file_comment_raw).into_owned(),
true => String::from_utf8_lossy(&file_comment_raw).into_owned(),
false => file_comment_raw.from_cp437(),
};

Copy path View file
@@ -34,7 +34,8 @@ impl CentralDirectoryEnd
let central_directory_size = try!(reader.read_u32::<LittleEndian>());
let central_directory_offset = try!(reader.read_u32::<LittleEndian>());
let zip_file_comment_length = try!(reader.read_u16::<LittleEndian>()) as usize;
let zip_file_comment = try!(reader.read_exact(zip_file_comment_length));
let mut zip_file_comment = vec![0; zip_file_comment_length];
try!(reader.read_exact(&mut zip_file_comment));

Ok(CentralDirectoryEnd
{
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.