Browse Source

Fix FatFile::printName() bug

Bill Greiman 5 years ago
parent
commit
41d8e42f2c
6 changed files with 15 additions and 18 deletions
  1. 1 1
      library.properties
  2. 9 12
      src/FatLib/FatFileLFN.cpp
  3. 1 1
      src/FatLib/FatVolume.cpp
  4. 2 2
      src/SdFat.h
  5. 1 1
      src/SdFatConfig.h
  6. 1 1
      src/SpiDriver/SdSpiTeensy3.cpp

+ 1 - 1
library.properties

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

+ 9 - 12
src/FatLib/FatFileLFN.cpp

@@ -502,9 +502,11 @@ fail:
 //------------------------------------------------------------------------------
 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;

+ 1 - 1
src/FatLib/FatVolume.cpp

@@ -357,7 +357,7 @@ fail:
 //------------------------------------------------------------------------------
 // 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);

+ 2 - 2
src/SdFat.h

@@ -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

+ 1 - 1
src/SdFatConfig.h

@@ -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

+ 1 - 1
src/SpiDriver/SdSpiTeensy3.cpp

@@ -25,7 +25,7 @@
 #include "SdSpiDriver.h"
 #if defined(__arm__) && defined(CORE_TEENSY)
 // SPI definitions
-#include "kinetis.h"
+// #include "kinetis.h"
 
 //------------------------------------------------------------------------------
 void SdSpiAltDriver::activate() {