1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
use std::fs;
use std::convert::AsRef;
use std::path::Path;

pub fn file_exists<P: AsRef<Path>>(path: P) -> bool {
    let metadata = fs::metadata(path);

    match metadata {
        Ok(md) => md.is_dir() || md.is_file(),
        Err(_) => false
    }
}