\r
\r
ofs = dp->dptr + SZDIRE; /* Next entry */\r
- if (dp->sect == 0 || ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) return FR_NO_FILE; /* Report EOT when offset has reached max value */\r
+ if (ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) dp->sect = 0; /* Disable it if the offset reached the max value */\r
+ if (dp->sect == 0) return FR_NO_FILE; /* Report EOT if it has been disabled */\r
\r
if (ofs % SS(fs) == 0) { /* Sector changed? */\r
dp->sect++; /* Next sector */\r