title: Fatfs significant slow down in directories with many files
body: <p>I have a data logging system running on an STM32F7 which is storing data using FatFs by ChaN to an SD card:
  <a href="http://elm-chan.org/fsw/ff/00index_e.html" rel="nofollow noreferrer">http://elm-chan.org/fsw/ff/00index_e.html</a></p>
  
  <p>Each new set of data is stored in a separate file withing a directory. During post-processing on the device, each file is read and then deleted. After testing the open, read, delete sequence in a directory with 5000 files I found that the further through the directory I scanned the slower it got.</p>
  
  <p>At the beginning this loop would take around 100-200ms, 2000 files in and now it takes 700 ms. Is there a quicker way of storing, reading, deleting data? or configuring FatFs?</p>
  
  <p>edit: Sorry should have specified, I am using FAT32 as the FAT file system</p>
  
  <pre><code>f_opendir(&amp;directory, "log");
  while(1) {
      f_readdir(&amp;directory, &amp;fInfo);
      if(fInfo.fname[0] == 0) {
        //end of the directory
        break;
      }
  
      if(fInfo.fname[0] == '.') {
        //ignore the dot entries
        continue;
      }
  
      if(fInfo.fattrib &amp; AM_DIR) {
        //its a directory (shouldnt be here), ignore it
        continue;
      }
  
      sprintf(path, "log/%s", fInfo.fname);
      f_open(&amp;file, path, FA_READ);
      f_read(&amp;file, rBuf, btr, &amp;br);
      f_close(&amp;file);
  
      //process data...
  
      f_unlink(path); //delete after processing
  }
  </code></pre>