Created
August 22, 2017 12:12
-
-
Save danmack/85a2b096926082fcfdddf59adbb0eaa9 to your computer and use it in GitHub Desktop.
This file contains 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
use std::path::Path; | |
fn main() { | |
let path = Path::new("./package"); | |
if path.exists() { | |
if path.is_dir() { | |
println!("{:?} is a directory", path); | |
} else { | |
println!("{:?} is not a directory", path); | |
} | |
} else { | |
println!("{:?} does not exist", path); | |
} | |
} | |
/* example: | |
$ touch package | |
$ ./target/debug/myisdir | |
"./package" is not a directory | |
$ rm package | |
$ mkdir package | |
$ ./target/debug/myisdir | |
"./package" is a directory | |
$ rm -rf package | |
$ ./target/debug/myisdir | |
"./package" does not exist | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment