file_type_enum 1.0.1

An enum with a variant for each file type.
Documentation

file_type_enum

Crates.io Docs.rs License

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

Contributing

Issues and PRs are welcome.

License: MIT