#include <string.h>\r
#include "header.h"\r
#include <readline.h>\r
+#include <errno.h>\r
\r
#define _stdin 0\r
#define _stdout 1\r
{"help", Command_Help}, {"clear", Command_Clear},\r
{"cd", Command_Cd}, {"dir", Command_Dir}\r
};\r
-static char *cDEFAULT_PATH[] = {"/Acess/Bin"};\r
+static char *cDEFAULT_PATH[] = {"/Acess/Bin","/Acess/SBin"};\r
#define BUILTIN_COUNT (sizeof(cBUILTINS)/sizeof(cBUILTINS[0]))\r
\r
// ==== LOCAL VARIABLES ====\r
- int giNumPathDirs = 1;\r
+ int giNumPathDirs = 2;\r
char **gasPathDirs = cDEFAULT_PATH;\r
char **gasEnvironment;\r
char gsCommandBuffer[1024];\r
// Read Command line\r
sCommandStr = Readline( readline_state );\r
printf("\n");\r
+ if( !sCommandStr ) {\r
+ perror("Readline");\r
+ return 1;\r
+ }\r
\r
// Parse Command Line into arguments\r
iArgCount = Parse_Args(sCommandStr, saArgs);\r
*/\r
void Command_Dir(int argc, char **argv)\r
{\r
- int dp, fp, dirLen;\r
+ int dp, fp;\r
char modeStr[11] = "RWXrwxRWX ";\r
- char tmpPath[1024];\r
- char *fileName;\r
+ char fileName[256];\r
t_sysFInfo info;\r
t_sysACL acl;\r
\r
+\r
+ // -- Generate and open directory --\r
// Generate Directory Path\r
+ char tmpPath[1024];\r
if(argc > 1)\r
- dirLen = GeneratePath(argv[1], gsCurrentDirectory, tmpPath);\r
+ GeneratePath(argv[1], gsCurrentDirectory, tmpPath);\r
else\r
- {\r
strcpy(tmpPath, gsCurrentDirectory);\r
- }\r
- dirLen = strlen(tmpPath);\r
- \r
// Open Directory\r
dp = _SysOpen(tmpPath, OPENFLAG_READ);\r
- // Check if file opened\r
- if(dp == -1)\r
- {\r
+ if(dp == -1) {\r
printf("Unable to open directory `%s', File cannot be found\n", tmpPath);\r
return;\r
}\r
return;\r
}\r
\r
- // Append Shash for file paths\r
- if(tmpPath[dirLen-1] != '/')\r
- {\r
- tmpPath[dirLen++] = '/';\r
- tmpPath[dirLen] = '\0';\r
- }\r
- \r
- fileName = (char*)(tmpPath+dirLen);\r
- // Read Directory Content\r
+ // -- Read Directory Contents --\r
while( (fp = _SysReadDir(dp, fileName)) )\r
{\r
if(fp < 0)\r
break;\r
}\r
// Open File\r
- fp = _SysOpen(tmpPath, 0);\r
+ fp = _SysOpenChild(dp, fileName, 0);\r
if(fp == -1) continue;\r
// Get File Stats\r
_SysFInfo(fp, &info, 0);\r