rune/languageserver/
fs.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::io;
use std::path::Path;

/// Test if the given path is a file.
pub(super) async fn is_file<P>(path: P) -> io::Result<bool>
where
    P: AsRef<Path>,
{
    match tokio::fs::metadata(path).await {
        Ok(m) => Ok(m.is_file()),
        Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(false),
        Err(e) => Err(e),
    }
}