Skip to content

Commit

Permalink
Fix FatFile::printName() bug
Browse files Browse the repository at this point in the history
  • Loading branch information
greiman committed Jan 25, 2020
1 parent 3b79f38 commit 41d8e42
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SdFat
version=1.1.0
version=1.1.1
license=MIT
author=Bill Greiman <[email protected]>
maintainer=Bill Greiman <[email protected]>
21 changes: 9 additions & 12 deletions src/FatLib/FatFileLFN.cpp
Original file line number Diff line number Diff line change
@@ -502,9 +502,11 @@ bool FatFile::open(FatFile* dirFile, fname_t* fname, oflag_t oflag) {
//------------------------------------------------------------------------------
size_t FatFile::printName(print_t* pr) {
FatFile dirFile;
uint16_t u;
size_t n = 0;
ldir_t* ldir;
size_t n = 0;
uint16_t u;
uint8_t buf[13];
uint8_t i;

if (!isLFN()) {
return printSFN(pr);
@@ -523,29 +525,24 @@ size_t FatFile::printName(print_t* pr) {
DBG_FAIL_MACRO;
goto fail;
}

if (ldir->attr != DIR_ATT_LONG_NAME ||
ord != (ldir->ord & 0X1F)) {
DBG_FAIL_MACRO;
goto fail;
}
for (uint8_t i = 0; i < 13; i++) {
for (i = 0; i < 13; i++) {
u = lfnGetChar(ldir, i);
if (u == 0) {
// End of name.
break;
}
if (u > 0X7E) {
u = '?';
}
pr->write(static_cast<char>(u));
buf[i] = u < 0X7F ? u : '?';
n++;
}
if (ldir->ord & LDIR_ORD_LAST_LONG_ENTRY) {
return n;
}
pr->write(buf, i);
}
// Fall into fail;
DBG_FAIL_MACRO;
return n;

fail:
return 0;
2 changes: 1 addition & 1 deletion src/FatLib/FatVolume.cpp
Original file line number Diff line number Diff line change
@@ -357,7 +357,7 @@ bool FatVolume::fatPut(uint32_t cluster, uint32_t value) {
//------------------------------------------------------------------------------
// free a cluster chain
bool FatVolume::freeChain(uint32_t cluster) {
uint32_t next;
uint32_t next = 0;
int8_t fg;
do {
fg = fatGet(cluster, &next);
4 changes: 2 additions & 2 deletions src/SdFat.h
Original file line number Diff line number Diff line change
@@ -36,8 +36,8 @@
#include "sdios.h"
#endif // INCLUDE_SDIOS
//------------------------------------------------------------------------------
/** SdFat version 1.1.0 */
#define SD_FAT_VERSION 10100
/** SdFat version 1.1.1 */
#define SD_FAT_VERSION 10101
//==============================================================================
/**
* \class SdBaseFile
2 changes: 1 addition & 1 deletion src/SdFatConfig.h
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@
#endif
//------------------------------------------------------------------------------
/**
* Set FAT12_SUPPORT nonzero to enable use if FAT12 volumes.
* Set FAT12_SUPPORT nonzero to enable use of FAT12 volumes.
* FAT12 has not been well tested and requires additional flash.
*/
#define FAT12_SUPPORT 0
2 changes: 1 addition & 1 deletion src/SpiDriver/SdSpiTeensy3.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
#include "SdSpiDriver.h"
#if defined(__arm__) && defined(CORE_TEENSY)
// SPI definitions
#include "kinetis.h"
// #include "kinetis.h"

//------------------------------------------------------------------------------
void SdSpiAltDriver::activate() {

0 comments on commit 41d8e42

Please sign in to comment.