An enum with a variant for each file type.
rust
pub enum FileType {
Regular,
Directory,
Symlink,
BlockDevice, // unix only
CharDevice, // unix only
Fifo, // unix only
Socket, // unix only
}
If you don't need an enum, check these methods from std instead:
Path::is_file].Path::is_dir].Path::is_symlink].```rust use filetypeenum::FileType;
fn main() -> io::Result<()> { let filetype = FileType::frompath("/tmp")?;
println!("There's a {} at {}!", file_type, path);
// Out: "There's a directory at /tmp!"
Ok(())
} ```
Note that the [FileType::from_path] follows symlinks and [FileType::from_symlink_path] does not.
AsRef<Path>], [fs::Metadata] and [std's FileType].libc::mode_t] (via the feature "mode-t-conversion").Issues and PRs are welcome.
License: MIT