You are currently viewing the documentation for:
ECF_ScanDirBegin
The ECF_ScanDirBegin function starts the scan of a directory.
ECF_ErrorCode ECF_ScanDirBegin(
   struct ECF_FileHandle *pScanDirPosition,
   const char *path
);
Parameters
pScanDirPosition
This a pointer to a struct ECF_FileHandle that EcFAT will use to keep track of the directory scan. You do not need to initialize the struct, ECF_ScanDirBegin will initialize it for you.
path
This is the path to scan. E.g. "A:\My directory" ("A:\\My directory" as a C string). The maximum total path length including the trailing NUL character is 260 characters.
Return value
Returns one of the EcFAT error codes (ECFERR_SUCCESS on success)
Remarks
None.
Example Code
void ListDirectory(const char *path)
{
   ECF_ErrorCode err;
   struct ECF_FileHandle scanHandle;
   struct ECF_FileDirectoryData fileData;
   
   // Error checking omitted
   ECF_ScanDirBegin(&scanHandle, path));

   while(ECFERR_SUCCESS == ECF_ScanDirNext(&scanHandle, &fileData))
   {
      // Skip the entry if it starts with .
      if(fileData.m_szFileName[0] == '.')
         continue;
      
      if(fileData.m_dirAttr & ECF_ATTR_DIRECTORY)
         printf("%s <DIR>\r\n", fileData.m_szFileName);
      else
         printf("%s\r\n", fileData.m_szFileName);
   }   
}
See also