Skip to content

Instantly share code, notes, and snippets.

@wunki
Created June 28, 2014 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wunki/b14f1654fb63fb9c0014 to your computer and use it in GitHub Desktop.
Save wunki/b14f1654fb63fb9c0014 to your computer and use it in GitHub Desktop.
#[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