@@ -47,7 +47,7 @@ class SDFSConfig : public FSConfig
4747public:
4848 static constexpr uint32_t FSId = 0x53444653 ;
4949
50- SDFSConfig (uint8_t csPin = 4 , SPISettings spi = SD_SCK_MHZ(10 )) : FSConfig(FSId, false ), _csPin(csPin), _part(0 ), _spiSettings(spi) { }
50+ SDFSConfig (uint8_t csPin = 4 , uint32_t spi = SD_SCK_MHZ(10 )) : FSConfig(FSId, false ), _csPin(csPin), _part(0 ), _spiSettings(spi) { }
5151
5252 SDFSConfig setAutoFormat (bool val = true ) {
5353 _autoFormat = val;
@@ -57,7 +57,7 @@ class SDFSConfig : public FSConfig
5757 _csPin = pin;
5858 return *this ;
5959 }
60- SDFSConfig setSPI (SPISettings spi) {
60+ SDFSConfig setSPI (uint32_t spi) {
6161 _spiSettings = spi;
6262 return *this ;
6363 }
@@ -67,9 +67,9 @@ class SDFSConfig : public FSConfig
6767 }
6868
6969 // Inherit _type and _autoFormat
70- uint8_t _csPin;
71- uint8_t _part;
72- SPISettings _spiSettings;
70+ uint8_t _csPin;
71+ uint8_t _part;
72+ uint32_t _spiSettings;
7373};
7474
7575class SDFSImpl : public FSImpl
@@ -97,11 +97,11 @@ class SDFSImpl : public FSImpl
9797 return false ;
9898 }
9999 info.maxOpenFiles = 999 ; // TODO - not valid
100- info.blockSize = _fs.vol ()->blocksPerCluster () * 512 ;
100+ info.blockSize = _fs.vol ()->sectorsPerCluster () * _fs. vol ()-> bytesPerSector () ;
101101 info.pageSize = 0 ; // TODO ?
102102 info.maxPathLength = 255 ; // TODO ?
103- info.totalBytes =_fs.vol ()->volumeBlockCount () * 512LL ;
104- info.usedBytes = info.totalBytes - (_fs.vol ()->freeClusterCount () * _fs.vol ()->blocksPerCluster () * 512LL );
103+ info.totalBytes =_fs.vol ()->clusterCount () * info. blockSize ;
104+ info.usedBytes = info.totalBytes - (_fs.vol ()->freeClusterCount () * _fs.vol ()->sectorsPerCluster () * _fs. vol ()-> bytesPerSector () );
105105 return true ;
106106 }
107107
@@ -156,7 +156,7 @@ class SDFSImpl : public FSImpl
156156 format ();
157157 _mounted = _fs.begin (_cfg._csPin , _cfg._spiSettings );
158158 }
159- sdfat::SdFile::dateTimeCallback (dateTimeCB);
159+ sdfat::FsDateTime::setCallback (dateTimeCB);
160160 return _mounted;
161161 }
162162
@@ -176,7 +176,7 @@ class SDFSImpl : public FSImpl
176176 return _fs.vol ()->fatType ();
177177 }
178178 size_t blocksPerCluster () {
179- return _fs.vol ()->blocksPerCluster ();
179+ return _fs.vol ()->sectorsPerCluster ();
180180 }
181181 size_t totalClusters () {
182182 return _fs.vol ()->clusterCount ();
@@ -185,7 +185,7 @@ class SDFSImpl : public FSImpl
185185 return (totalClusters () / blocksPerCluster ());
186186 }
187187 size_t clusterSize () {
188- return blocksPerCluster () * 512 ; // 512b block size
188+ return blocksPerCluster () * _fs. vol ()-> bytesPerSector ();
189189 }
190190 size_t size () {
191191 return (clusterSize () * totalClusters ());
@@ -264,7 +264,7 @@ class SDFSImpl : public FSImpl
264264class SDFSFileImpl : public FileImpl
265265{
266266public:
267- SDFSFileImpl (SDFSImpl *fs, std::shared_ptr<sdfat::File > fd, const char *name)
267+ SDFSFileImpl (SDFSImpl *fs, std::shared_ptr<sdfat::File32 > fd, const char *name)
268268 : _fs(fs), _fd(fd), _opened(true )
269269 {
270270 _name = std::shared_ptr<char >(new char [strlen (name) + 1 ], std::default_delete<char []>());
@@ -295,7 +295,6 @@ class SDFSFileImpl : public FileImpl
295295 void flush () override
296296 {
297297 if (_opened) {
298- _fd->flush ();
299298 _fd->sync ();
300299 }
301300 }
@@ -375,15 +374,15 @@ class SDFSFileImpl : public FileImpl
375374
376375 bool isDirectory () const override
377376 {
378- return _opened ? _fd->isDirectory () : false ;
377+ return _opened ? _fd->isDir () : false ;
379378 }
380379
381380 time_t getLastWrite () override {
382381 time_t ftime = 0 ;
383382 if (_opened && _fd) {
384- sdfat::dir_t tmp;
383+ sdfat::DirFat_t tmp;
385384 if (_fd.get ()->dirEntry (&tmp)) {
386- ftime = SDFSImpl::FatToTimeT (tmp.lastWriteDate , tmp.lastWriteTime );
385+ ftime = SDFSImpl::FatToTimeT (*( uint16_t *) tmp.modifyDate , *( uint16_t *) tmp.modifyTime );
387386 }
388387 }
389388 return ftime;
@@ -392,9 +391,9 @@ class SDFSFileImpl : public FileImpl
392391 time_t getCreationTime () override {
393392 time_t ftime = 0 ;
394393 if (_opened && _fd) {
395- sdfat::dir_t tmp;
394+ sdfat::DirFat_t tmp;
396395 if (_fd.get ()->dirEntry (&tmp)) {
397- ftime = SDFSImpl::FatToTimeT (tmp.creationDate , tmp.creationTime );
396+ ftime = SDFSImpl::FatToTimeT (*( uint16_t *) tmp.createDate , *( uint16_t *) tmp.createTime );
398397 }
399398 }
400399 return ftime;
@@ -404,15 +403,15 @@ class SDFSFileImpl : public FileImpl
404403
405404protected:
406405 SDFSImpl* _fs;
407- std::shared_ptr<sdfat::File > _fd;
406+ std::shared_ptr<sdfat::File32 > _fd;
408407 std::shared_ptr<char > _name;
409408 bool _opened;
410409};
411410
412411class SDFSDirImpl : public DirImpl
413412{
414413public:
415- SDFSDirImpl (const String& pattern, SDFSImpl* fs, std::shared_ptr<sdfat::File > dir, const char *dirPath = nullptr )
414+ SDFSDirImpl (const String& pattern, SDFSImpl* fs, std::shared_ptr<sdfat::File32 > dir, const char *dirPath = nullptr )
416415 : _pattern(pattern), _fs(fs), _dir(dir), _valid(false ), _dirPath(nullptr )
417416 {
418417 if (dirPath) {
@@ -487,17 +486,17 @@ class SDFSDirImpl : public DirImpl
487486 {
488487 const int n = _pattern.length ();
489488 do {
490- sdfat::File file;
489+ sdfat::File32 file;
491490 file.openNext (_dir.get (), sdfat::O_READ);
492491 if (file) {
493492 _valid = 1 ;
494493 _size = file.fileSize ();
495494 _isFile = file.isFile ();
496- _isDirectory = file.isDirectory ();
497- sdfat::dir_t tmp;
495+ _isDirectory = file.isDir ();
496+ sdfat::DirFat_t tmp;
498497 if (file.dirEntry (&tmp)) {
499- _time = SDFSImpl::FatToTimeT (tmp.lastWriteDate , tmp.lastWriteTime );
500- _creation = SDFSImpl::FatToTimeT (tmp.creationDate , tmp.creationTime );
498+ _time = SDFSImpl::FatToTimeT (*( uint16_t *) tmp.modifyDate , *( uint16_t *) tmp.modifyTime );
499+ _creation = SDFSImpl::FatToTimeT (*( uint16_t *) tmp.createDate , *( uint16_t *) tmp.createTime );
501500 } else {
502501 _time = 0 ;
503502 _creation = 0 ;
@@ -521,7 +520,7 @@ class SDFSDirImpl : public DirImpl
521520protected:
522521 String _pattern;
523522 SDFSImpl* _fs;
524- std::shared_ptr<sdfat::File > _dir;
523+ std::shared_ptr<sdfat::File32 > _dir;
525524 bool _valid;
526525 char _lfn[64 ];
527526 time_t _time;
0 commit comments