summary refs log tree commit diff
path: root/progs/ls/ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'progs/ls/ls.c')
-rw-r--r--progs/ls/ls.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/progs/ls/ls.c b/progs/ls/ls.c
index 976e8c9..cdac6e8 100644
--- a/progs/ls/ls.c
+++ b/progs/ls/ls.c
@@ -42,7 +42,17 @@ int main(int argc, char *argv[]) {
     //TODO - sort
     if (d) {
         while ((dir = readdir(d)) != NULL) {
-            printf("%s\n", dir->d_name);
+            struct stat path_stat;
+            char path[256] = {0};
+            joinPath(path, dirp, dir->d_name);
+            stat(path, &path_stat);
+            if (S_ISDIR(path_stat.st_mode)) { 
+                printf("\e[94m%s\e[0m\n", dir->d_name);
+            } else if (!access(path, X_OK)) {
+                printf("\e[92m%s\e[0m\n", dir->d_name);
+            } else {
+                printf("%s\n", dir->d_name);
+            }
         }
         closedir(d);
     }