Tool/software: Code Composer Studio
Hi Team,
I can you help me understand what is missing. I am stuck with this code...
I am trying to perform 'ls' command with the below code.
it seems that I always get the number of files read is 0
I am using terminal pushes for debug and I always get 1..1c..2, when running the below code,
which means f_opendir and f_readdir seems to work , but the returned file name
(gFsShellAppUtilsFileInfo.fname[0]) is always NULL
TerminalOutPush("1..");
/* Open the current directory for access. */
strcpy(gFsShellAppUtilsCwd, "0:");
fresult = f_opendir(&gFsShellAppUtilsDirObj, gFsShellAppUtilsCwd);
if (FR_OK != fresult)
{
TerminalOutPush("1a.."); code never goes here .. no error
state = 2;
break;
}
/* Read an entry from the directory. */
fresult = f_readdir(&gFsShellAppUtilsDirObj, &gFsShellAppUtilsFileInfo);
if (FR_OK != fresult)
{
TerminalOutPush("1b.."); code never goes here .. no error
state = 2;
break;
}
/* If the file name is blank, then this is the end of the listing. */
if('\0' == gFsShellAppUtilsFileInfo.fname[0])
{
TerminalOutPush("1c..");code always enters here on the first read
TerminalOutPush(gFsShellAppUtilsFileInfo.fname);
state = 2;
break;
}
/* If the attribute is directory, then increment the directory count. */
if(AM_DIR == (gFsShellAppUtilsFileInfo.fattrib & AM_DIR))
{
dirCount++;
TerminalOutPush("1d.."); code never goes here .. no directories read
}
else // its a file
{
fileCount++; code never goes here .. file count is zero
totalSize += gFsShellAppUtilsFileInfo.fsize;
TerminalOutPush("1e..");
}
