Created
June 28, 2014 13:22
-
-
Save wunki/b14f1654fb63fb9c0014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[crate_id="cherr"] | |
use std::os; | |
use std::io::fs; | |
fn main() { | |
// get the filename | |
let args = os::args(); | |
let filename: &str = args.get(1).as_slice(); | |
// check if the file exists | |
let path = Path::new(filename); | |
if !path.exists() { | |
fail!("The file you wanted to upload does not exist!"); | |
} | |
let stat = match path.stat() { | |
Err(why) => fail!("{}", why.desc), | |
Ok(stat) => stat, | |
}; | |
// get the mimetype of the file | |
println!("The size of the file you try to upload is: {}", stat.size); | |
println!("The file you want to upload: {}", filename); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment