Do not use feature exit_status
This commit is contained in:
parent
b4d7747966
commit
a328b8ba2c
3 changed files with 25 additions and 14 deletions
|
@ -1,17 +1,18 @@
|
|||
#![feature(exit_status)]
|
||||
|
||||
extern crate zip;
|
||||
|
||||
use std::io;
|
||||
use std::fs;
|
||||
|
||||
fn main()
|
||||
fn main() {
|
||||
std::process::exit(real_main());
|
||||
}
|
||||
|
||||
fn real_main() -> i32
|
||||
{
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
if args.len() < 2 {
|
||||
println!("Usage: {} <filename>", args[0]);
|
||||
std::env::set_exit_status(1);
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
let fname = std::path::Path::new(&*args[1]);
|
||||
let file = fs::File::open(&fname).unwrap();
|
||||
|
@ -38,6 +39,8 @@ fn main()
|
|||
write_file(&mut file, &outpath);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn write_file(reader: &mut zip::read::ZipFile, outpath: &std::path::Path)
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
#![feature(exit_status)]
|
||||
|
||||
use std::io::prelude::*;
|
||||
|
||||
extern crate zip;
|
||||
|
||||
fn main()
|
||||
{
|
||||
std::process::exit(real_main());
|
||||
}
|
||||
|
||||
fn real_main() -> i32
|
||||
{
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
if args.len() < 2 {
|
||||
println!("Usage: {} <filename>", args[0]);
|
||||
std::env::set_exit_status(1);
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
let fname = std::path::Path::new(&*args[1]);
|
||||
let zipfile = std::fs::File::open(&fname).unwrap();
|
||||
|
@ -20,10 +22,12 @@ fn main()
|
|||
let mut file = match archive.by_name("test/lorem_ipsum.txt")
|
||||
{
|
||||
Ok(file) => file,
|
||||
Err(..) => { println!("File test/lorem_ipsum.txt not found"); return }
|
||||
Err(..) => { println!("File test/lorem_ipsum.txt not found"); return 2;}
|
||||
};
|
||||
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents).unwrap();
|
||||
println!("{}", contents);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
#![feature(exit_status)]
|
||||
|
||||
use std::io::prelude::*;
|
||||
|
||||
extern crate zip;
|
||||
|
||||
fn main()
|
||||
{
|
||||
std::process::exit(real_main());
|
||||
}
|
||||
|
||||
fn real_main() -> i32
|
||||
{
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
if args.len() < 2 {
|
||||
println!("Usage: {} <filename>", args[0]);
|
||||
std::env::set_exit_status(1);
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
let filename = &*args[1];
|
||||
|
@ -19,6 +21,8 @@ fn main()
|
|||
Ok(_) => println!("File written to {}", filename),
|
||||
Err(e) => println!("Error: {:?}", e),
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn doit(filename: &str) -> zip::result::ZipResult<()>
|
||||
|
|
Loading…
Add table
Reference in a new issue