char RecivePcBuf[30];
char Filename[30];
char temp_data[30];
int i;
unsigned short usBytesRead;
char g_cTmpBuf[30];
//int flag_Cmd;
char SendPc[100];
FRESULT fresult;
unsigned char FROK;
char *temp;
//File_Name[0]='\0';
temp_data[0]=0;
RecivePcBuf[0]=0;
g_cTmpBuf[0]=0;
strcpy(RecivePcBuf,p);
//RecivePcBuf=p;
RecivePcBuf[len]='\0';
if ((RecivePcBuf[0]=='l')&&(RecivePcBuf[1]=='s'))
{
//FROK=tcp_write(pcb,"su",strlen("su"),0);
SendPc[0]=0;
fresult = f_opendir(&g_sDirObject, g_cCwdBuf);
//
// Check for error and return if there is a problem.
//
if(fresult != FR_OK)
{
UARTprintf("openirfail!");
return(fresult);
}
for(;;)
{
//
// Read an entry from the directory.
//
fresult = f_readdir(&g_sDirObject, &g_sFileInfo);
//
// Check for error and return if there is a problem.
//
if(fresult != FR_OK)
{
UARTprintf("readdirfail!");
return(fresult);
}
//
// If the file name is blank, then this is the end of the
// listing.
//
if(!g_sFileInfo.fname[0])
{
UARTprintf("blankname!");
break;
}
//
// If the attribue is directory, then increment the directory count.
//
if(g_sFileInfo.fattrib & AM_DIR)
{
strcat(SendPc,"D---- ");
}
else
{
if (g_sFileInfo.fattrib & AM_ARC)
{
strcat(SendPc,"----A ");
}
}
strcat(SendPc,g_sFileInfo.fname);
strcat(SendPc,"\0");
}
strcat(SendPc,"\0");
UARTprintf(SendPc);
FROK=tcp_write(pcb,SendPc,strlen(SendPc),0);
if (FROK!=ERR_OK)
{
UARTprintf("lstcpfail");
return 0;
}
FROK=tcp_output(pcb);
if (FROK!=ERR_OK)
{
return 0;
}