Procházet zdrojové kódy

Fix open LFN by index

main
Bill Greiman před 5 roky
rodič
revize
95551112eb
4 změnil soubory, kde provedl 40 přidání a 8 odebrání
  1. +1
    -1
      library.properties
  2. +1
    -1
      src/ExFatLib/ExFatFile.cpp
  3. +37
    -4
      src/FatLib/FatFile.cpp
  4. +1
    -2
      src/FatLib/FatFileLFN.cpp

+ 1
- 1
library.properties Zobrazit soubor

@@ -1,5 +1,5 @@
name=SdFat
version=2.0.0-beta.4
version=2.0.0-beta.5
license=MIT
author=Bill Greiman <fat16lib@sbcglobal.net>
maintainer=Bill Greiman <fat16lib@sbcglobal.net>

+ 1
- 1
src/ExFatLib/ExFatFile.cpp Zobrazit soubor

@@ -612,7 +612,7 @@ int ExFatFile::read(void* buf, size_t count) {
// Check for cache sector in read range.
if (sector <= m_vol->dataCacheSector()
&& m_vol->dataCacheSector() < (sector + ns)) {
// Flush cache if a cache sector is in the range.
// Flush cache if cache sector is in the range.
if (!m_vol->dataCacheSync()) {
DBG_FAIL_MACRO;
goto fail;

+ 37
- 4
src/FatLib/FatFile.cpp Zobrazit soubor

@@ -454,13 +454,46 @@ fail:
}
//------------------------------------------------------------------------------
bool FatFile::open(FatFile* dirFile, uint16_t index, oflag_t oflag) {
if (dirFile->seekSet(32*index) && openNext(dirFile, oflag)) {
if (dirIndex() == index) {
return true;
if (index) {
// Find start of LFN.
DirLfn_t* ldir;
uint8_t n = index < 20 ? index : 20;
for (uint8_t i = 1; i <= n; i++) {
if (!dirFile->seekSet(32UL*(index - i))) {
DBG_FAIL_MACRO;
goto fail;
}
ldir = reinterpret_cast<DirLfn_t*>(dirFile->readDirCache());
if (!ldir) {
DBG_FAIL_MACRO;
goto fail;
}
if (ldir->attributes != FAT_ATTRIB_LONG_NAME) {
break;
}
if (ldir->order & FAT_ORDER_LAST_LONG_ENTRY) {
if (!dirFile->seekSet(32UL*(index - i))) {
DBG_FAIL_MACRO;
goto fail;
}
break;
}
}
} else {
dirFile->rewind();
}
if (!openNext(dirFile, oflag)) {
DBG_FAIL_MACRO;
goto fail;
}
if(dirIndex() != index) {
close();
DBG_FAIL_MACRO;
goto fail;
}
return true;

fail:
return false;
}
//------------------------------------------------------------------------------
@@ -732,7 +765,7 @@ int FatFile::read(void* buf, size_t nbyte) {
// Check for cache sector in read range.
if (sector <= m_vol->cacheSectorNumber()
&& sector < (m_vol->cacheSectorNumber() + ns)) {
// Flush cache if a cache sector is in the range.
// Flush cache if cache sector is in the range.
if (!m_vol->cacheSyncData()) {
DBG_FAIL_MACRO;
goto fail;

+ 1
- 2
src/FatLib/FatFileLFN.cpp Zobrazit soubor

@@ -558,7 +558,6 @@ fail:
bool FatFile::remove() {
bool last;
uint8_t checksum;
uint8_t order;
FatFile dirFile;
DirFat_t* dir;
DirLfn_t* ldir;
@@ -601,7 +600,7 @@ bool FatFile::remove() {
DBG_FAIL_MACRO;
goto fail;
}
for (order = 1; order <= m_lfnOrd; order++) {
for (uint8_t order = 1; order <= m_lfnOrd; order++) {
if (!dirFile.seekSet(32UL*(m_dirIndex - order))) {
DBG_FAIL_MACRO;
goto fail;

Načítá se…
Zrušit
Uložit