From eff87440fa3f0a981ad409c9bd34cd485db9df4b Mon Sep 17 00:00:00 2001 From: Ben S Date: Sat, 21 Jun 2014 18:27:26 +0100 Subject: [PATCH] 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. --- file.rs | 2 +- filetype.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/file.rs b/file.rs index daa5fb6..9a00022 100644 --- a/file.rs +++ b/file.rs @@ -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(), } } diff --git a/filetype.rs b/filetype.rs index 1d44901..894fb52 100644 --- a/filetype.rs +++ b/filetype.rs @@ -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; } -- GitLab