Przeglądaj źródła

Fix readdir bug (issue #7)

main
PaulStoffregen 9 lat temu
rodzic
commit
c3d052f680
1 zmienionych plików z 8 dodań i 3 usunięć
  1. +8
    -3
      SerialFlashDirectory.cpp

+ 8
- 3
SerialFlashDirectory.cpp Wyświetl plik

uint32_t maxfiles, index, straddr; uint32_t maxfiles, index, straddr;
uint32_t i, n; uint32_t i, n;
uint32_t buf[2]; uint32_t buf[2];
uint16_t hash;
char str[16], *p=filename; char str[16], *p=filename;


filename[0] = 0; filename[0] = 0;
if (!maxfiles) return false; if (!maxfiles) return false;
maxfiles &= 0xFFFF; maxfiles &= 0xFFFF;
index = dirindex; index = dirindex;
if (index >= maxfiles) return false;
while (1) {
if (index >= maxfiles) return false;
//Serial.printf("readdir, index = %u\n", index);
SerialFlash.read(8 + index * 2, &hash, 2);
if (hash != 0) break;
index++; // skip deleted entries
}
dirindex = index + 1; dirindex = index + 1;
//Serial.printf("readdir, index = %u\n", index);

buf[1] = 0; buf[1] = 0;
SerialFlash.read(8 + 4 + maxfiles * 2 + index * 10, buf, 6); SerialFlash.read(8 + 4 + maxfiles * 2 + index * 10, buf, 6);
if (buf[0] == 0xFFFFFFFF) return false; if (buf[0] == 0xFFFFFFFF) return false;

Ładowanie…
Anuluj
Zapisz