Esempio n. 1
0
struct dirent * FS_ReadDir( FS_DIR *dirp)
{
	_FS_PTR * dir = (_FS_PTR *) dirp;

	FILINFO FileInfo;
	static struct dirent ent;
	char *fn;
#if _USE_LFN
	static WCHAR lfn[_MAX_LFN+1];
	FileInfo.lfname = (TCHAR*)lfn;
	FileInfo.lfsize = sizeof(lfn);
#endif

	ent.d_name[0]=0;

	if (dirp == 0) {
  		return 0;  /* Device not found */
	}

	 FS_X_OS_LockDirOp();

	 dir->error = f_readdir (
	  &dir->fs.dir,	 /* Pointer to the open directory object */
	  &FileInfo  /* Pointer to the file information structure */
	);

   if(dir->error!=FR_OK)
   {
   	  FS_X_OS_UnlockDirOp();
	  ent.d_name[0]=0;
	  ent.st_mode=0;
	  ent.id = 0;
	  ent.st_ctime = 0;

	  return 0;
   }

#if _USE_LFN
   fn = (char *)(*FileInfo.lfname ? FileInfo.lfname : FileInfo.fname);
#else
   fn = (char *)FileInfo.fname;
#endif

   if(FileInfo.fname[0] == 0) //end
	 ent.d_name[0]=0;
   else
   	strcpy(ent.d_name,fn);

   ent.st_mode = (FileInfo.fattrib & AM_DIR)?_IFDIR:0;
   ent.id = FileInfo.fsize;
   ent.st_ctime = FileInfo.ftime|(FileInfo.fdate<<16);

   FS_X_OS_UnlockDirOp();
   
   return &ent;
}
Esempio n. 2
0
struct FS_DIRENT *FS_ReadDir(FS_DIR *pDir) {
  struct FS_DIRENT *entry;

  if (!pDir) {
    return 0;  /* No pointer to a FS_DIR data structure */
  }
  FS_X_OS_LockDirOp(pDir);
  entry = 0;
  if (pDir->dev_index >= 0) {
    if (FS__pDevInfo[pDir->dev_index].fs_ptr->fsl_readdir) {
      /* Execute FSL function */
      entry = (FS__pDevInfo[pDir->dev_index].fs_ptr->fsl_readdir)(pDir);
    }
  }
  FS_X_OS_UnlockDirOp(pDir);
  return entry;  
}