Fix unstable things in the demos

This commit is contained in:
Mathijs van de Nes 2015-01-10 15:28:41 +01:00
parent 1a62f9ce16
commit b4f04ab79b
3 changed files with 12 additions and 6 deletions

View file

@ -1,3 +1,5 @@
#![allow(unstable)]
extern crate zip; extern crate zip;
fn main() fn main()
@ -8,14 +10,14 @@ fn main()
std::os::set_exit_status(1); std::os::set_exit_status(1);
return; return;
} }
let fname = Path::new(args[1].as_slice()); let fname = Path::new(&*args[1]);
let file = std::io::File::open(&fname).unwrap(); let file = std::io::File::open(&fname).unwrap();
let zipcontainer = zip::ZipReader::new(file).unwrap(); let zipcontainer = zip::ZipReader::new(file).unwrap();
for file in zipcontainer.files() for file in zipcontainer.files()
{ {
let outpath = sanitize_filename(file.file_name.as_slice()); let outpath = sanitize_filename(&*file.file_name);
println!("{}", outpath.display()); println!("{}", outpath.display());
let comment = &file.file_comment; let comment = &file.file_comment;
@ -23,7 +25,7 @@ fn main()
std::io::fs::mkdir_recursive(&outpath.dir_path(), std::io::USER_DIR).unwrap(); std::io::fs::mkdir_recursive(&outpath.dir_path(), std::io::USER_DIR).unwrap();
if file.file_name.as_slice().ends_with("/") { if (&*file.file_name).ends_with("/") {
create_directory(outpath); create_directory(outpath);
} }
else { else {
@ -48,7 +50,7 @@ fn create_directory(outpath: Path)
fn sanitize_filename(filename: &str) -> Path fn sanitize_filename(filename: &str) -> Path
{ {
let no_null_filename = match filename.find('\0') { let no_null_filename = match filename.find('\0') {
Some(index) => filename.slice_to(index), Some(index) => &filename[0..index],
None => filename, None => filename,
}; };

View file

@ -1,3 +1,5 @@
#![allow(unstable)]
extern crate zip; extern crate zip;
fn main() fn main()
@ -8,7 +10,7 @@ fn main()
std::os::set_exit_status(1); std::os::set_exit_status(1);
return; return;
} }
let fname = Path::new(args[1].as_slice()); let fname = Path::new(&*args[1]);
let file = std::io::File::open(&fname).unwrap(); let file = std::io::File::open(&fname).unwrap();
let zipcontainer = zip::ZipReader::new(file).unwrap(); let zipcontainer = zip::ZipReader::new(file).unwrap();

View file

@ -1,3 +1,5 @@
#![allow(unstable)]
extern crate zip; extern crate zip;
fn main() fn main()
@ -9,7 +11,7 @@ fn main()
return; return;
} }
let filename = args[1].as_slice(); let filename = &*args[1];
match doit(filename) match doit(filename)
{ {
Ok(_) => println!("File written to {}", filename), Ok(_) => println!("File written to {}", filename),