Explorar el Código

Highlight executable files in green

This was intended from the start, but the dead_code checker was dulled by the module being public!
Ben S hace 10 años
padre
commit
b4529671b8
Se han modificado 2 ficheros con 8 adiciones y 0 borrados
  1. 5 0
      src/file.rs
  2. 3 0
      src/filetype.rs

+ 5 - 0
src/file.rs

@@ -94,6 +94,11 @@ impl<'a> File<'a> {
         self.stat.is_file()
     }
 
+    pub fn is_executable_file(&self) -> bool {
+        let bit = unix::fs::USER_EXECUTE;
+        self.is_file() && (self.stat.permissions().mode() & bit) == bit
+    }
+
     pub fn is_link(&self) -> bool {
         self.stat.file_type().is_symlink()
     }

+ 3 - 0
src/filetype.rs

@@ -85,6 +85,9 @@ impl<'a> HasType for File<'a> {
         if self.is_directory() {
             return Directory;
         }
+        else if self.is_executable_file() {
+            return Executable;
+        }
         else if self.is_link() {
             return Symlink;
         }