Skip to main content

is_file

Function is_file 

Source
pub fn is_file(path: &Path) -> bool
Expand description

Whether path exists and is a regular file — false on any error, including a missing path.

Deliberately rejects a FIFO, socket, character device, or directory at path: unlike a regular file, reading one of those can block the calling thread indefinitely, which would stall the parse. std::fs::metadata follows symlinks, so a symlinked regular file still resolves as a file here.

Callers that already hold a std::fs::Metadata from metadata (as crate::mtime_cache::MtimeFileCache does) should call .is_file() on it directly rather than re-probing through here.

§Examples

use deps_core::fs_probe::is_file;
use std::path::Path;

assert!(!is_file(Path::new("/nonexistent/path/to/nowhere")));