int dp, fp, dirLen;\r
//char modeStr[11] = "RWXrwxRWX ";\r
char tmpPath[1024];\r
- char fileName[256];\r
+ char *fileName;\r
t_sysFInfo info;\r
\r
// Generate Directory Path\r
tmpPath[dirLen++] = '/';\r
tmpPath[dirLen] = '\0';\r
}\r
+ \r
+ fileName = (char*)(tmpPath+dirLen);\r
// Read Directory Content\r
while( (fp = readdir(dp, fileName)) )\r
{\r
write(_stdout, 42, "Invalid Permissions to traverse directory\n");\r
break;\r
}\r
- // Create File Path\r
- strcpy((char*)(tmpPath+dirLen), fileName);\r
// Open File\r
fp = open(tmpPath, 0);\r
if(fp == -1) continue;\r
close(fp);\r
\r
// Colour Code\r
- write(_stdout, 6, "\x1B[37m"); //White\r
- if(info.flags & FILEFLAG_DIRECTORY) //Directory Green\r
+ if(info.flags & FILEFLAG_DIRECTORY) // Directory: Green\r
write(_stdout, 6, "\x1B[32m");\r
+ else\r
+ write(_stdout, 6, "\x1B[37m"); // Default: White\r
\r
//Print Mode\r
#if 0\r
write(_stdout, 10, modeStr);\r
#endif\r
\r
- //Print Name\r
+ // Print Name\r
write(_stdout, strlen(fileName), fileName);\r
- //Print slash if applicable\r
+ // Print slash if applicable\r
if(info.flags & FILEFLAG_DIRECTORY)\r
write(_stdout, 1, "/");\r
\r
- // Revert Colout and end line\r
+ // Revert Colour and end line\r
write(_stdout, 6, "\x1B[37m");\r
- write(_stdout, 2, "\n");\r
+ write(_stdout, 1, "\n");\r
}\r
// Close Directory\r
close(dp);\r