Do similar for block devices and named pipes

There doesn't seem to be an io::FileType entry for character special
devices or sockets, so these fall under the io::UnknownType entry. Which
also gets highlighted in yellow, for precisely that reason.
This commit is contained in:
Ben S 2014-06-21 18:27:26 +01:00
parent a542fdc9f9
commit eff87440fa
2 changed files with 6 additions and 2 deletions

View File

@ -145,7 +145,7 @@ impl<'a> File<'a> {
io::TypeNamedPipe => Yellow.paint("|"),
io::TypeBlockSpecial => Purple.paint("s"),
io::TypeSymlink => Cyan.paint("l"),
_ => "?".to_string(),
io::TypeUnknown => "?".to_string(),
}
}

View File

@ -3,7 +3,7 @@ use file::File;
use std::io;
pub enum FileType {
Normal, Directory, Executable, Immediate, Compiled, Symlink,
Normal, Directory, Executable, Immediate, Compiled, Symlink, Special,
Image, Video, Music, Lossless, Compressed, Document, Temp, Crypto,
}
@ -46,6 +46,7 @@ impl FileType {
Normal => Plain,
Directory => Blue.bold(),
Symlink => Cyan.normal(),
Special => Yellow.normal(),
Executable => Green.bold(),
Image => Fixed(133).normal(),
Video => Fixed(135).normal(),
@ -73,6 +74,9 @@ impl<'a> HasType for File<'a> {
else if self.stat.kind == io::TypeSymlink {
return Symlink;
}
else if self.stat.kind == io::TypeBlockSpecial || self.stat.kind == io::TypeNamedPipe || self.stat.kind == io::TypeUnknown {
return Special;
}
else if self.stat.perm.contains(io::UserExecute) {
return Executable;
}