Parcourir la source

sdfat: Use dataLength() instead of size() to get correct file size no matter the underlying filesystem. Fixes #258

Eric Helgeson il y a 4 mois
Parent
commit
9063091b1f
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      src/ImageBackingStore.cpp

+ 2 - 2
src/ImageBackingStore.cpp

@@ -136,7 +136,7 @@ bool ImageBackingStore::_internal_open(const char *filename)
         return false;
     }
 
-    uint32_t sectorcount = m_fsfile.size() / SD_SECTOR_SIZE;
+    uint32_t sectorcount = m_fsfile.dataLength() / SD_SECTOR_SIZE;
     uint32_t begin = 0, end = 0;
     if (m_fsfile.contiguousRange(&begin, &end) && end >= begin + sectorcount - 1)
     {
@@ -236,7 +236,7 @@ uint64_t ImageBackingStore::size()
     }
     else
     {
-        return m_fsfile.size();
+        return m_fsfile.dataLength();
     }
 }