file_type_enum
An enum with a variant for each file type.
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:
Example
use file_type_enum::FileType;
use std::io;
fn main() -> io::Result<()> {
let file_type = FileType::from_path("/tmp")?;
println!("There's a {} at /tmp", file_type);
// Out: "There's a directory at /tmp"
Ok(())
}
Note that the FileType::from_path
follows symlinks and FileType::from_symlink_path
does not.
Conversions
- From
AsRef<Path>
,fs::Metadata
and std'sFileType
. - From and into
libc::mode_t
(via the feature"mode-t-conversion"
).
Contributing
Issues and PRs are welcome.
License: MIT