2 unstable releases
Uses old Rust 2015
0.2.0 | Apr 30, 2015 |
---|---|
0.1.0 | Apr 29, 2015 |
#48 in #fs-file
8KB
112 lines
This is a pet project, and not tested very well (contributions welcome!). Use at your own risk.
This crate provides a basic extension to std::fs::File
: it defines a method
which returns the file's type (on *nix systems).
extern crate filetype;
use std::fs;
use std::fs::File;
use filetype::{FileType, UnixFileType};
let f = File::open("foo").unwrap();
let ftype = f.file_type().unwrap();
match ftype {
FileType::Regular => {},
FileType::Directory => {},
FileType::Symlink => {},
FileType::NamedPipe => {},
FileType::BlockDevice => {},
FileType::CharacterDevice => {},
}
lib.rs
:
This crate provides a basic extension to std::fs::File
: it defines a method
which returns the file's type (on *nix systems).
use std::fs;
use std::fs::File;
use filetype::{FileType, UnixFileType};
let f = File::open("foo").unwrap();
let ftype = f.file_type().unwrap();
match ftype {
FileType::Regular => {},
FileType::Directory => {
# assert!(false);
},
FileType::Symlink => {
# assert!(false);
},
FileType::NamedPipe => {
# assert!(false);
},
FileType::BlockDevice => {
# assert!(false);
},
FileType::CharacterDevice => {
# assert!(false);
},
}
Dependencies
~1.5MB
~35K SLoC