This crate grants a enum with one variant for each file type.
Cross-platform and small, this crate has a single file with around 150
lines of source code. Simplest implementation, should be in std
. If you
want to check file types, here's a enum for you, don't rewrite it.
Enum FileType:
Examples:
use FileType;
Note: FileType::from_path(path)
returns a io::Error if:
- Path does not exist.
- The user lacks permissions to read metadata on the path.
For each variant, there's a short hand .is_VARIANT()
:
file_type.is_file()
for FileType::File
,
file_type.is_directory()
for FileType::Directory
,
file_type.is_symlink()
for FileType::Symlink
,
And so on...
use FileType;
By default, if path
points to symlink FileType::from_path()
considers
the path at the symlink's target location (this implies that the returned
file type can't be FileType::Symlink
).
If you don't wanna follow symlinks, use FileType::from_symlink_path
instead, this function may return Ok(FileType::Symlink)
.
use FileType;
FileType::from::<fs::FileType>(fs_ft)
is also available.
Helping and contributing:
It's easy to contribute to this crate, here are some options:
- Share it to a friend.
- Help improve this README.md, even with little details.
- Open issues to the repository.
- Leave a star on GitHub.
- Use it!