@@ -47,7 +47,7 @@ class SDFSConfig : public FSConfig
4747public:
4848static 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 SDFSConfigsetAutoFormat (bool val =true ) {
5353 _autoFormat = val;
@@ -57,7 +57,7 @@ class SDFSConfig : public FSConfig
5757 _csPin = pin;
5858return *this ;
5959 }
60- SDFSConfigsetSPI (SPISettings spi) {
60+ SDFSConfigsetSPI (uint32_t spi) {
6161 _spiSettings = spi;
6262return *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
9797return 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 () );
105105return true ;
106106 }
107107
@@ -156,7 +156,7 @@ class SDFSImpl : public FSImpl
156156format ();
157157 _mounted = _fs.begin (_cfg._csPin , _cfg._spiSettings );
158158 }
159- sdfat::SdFile::dateTimeCallback (dateTimeCB);
159+ sdfat::FsDateTime::setCallback (dateTimeCB);
160160return _mounted;
161161 }
162162
@@ -176,7 +176,7 @@ class SDFSImpl : public FSImpl
176176return _fs.vol ()->fatType ();
177177 }
178178size_t blocksPerCluster () {
179- return _fs.vol ()->blocksPerCluster ();
179+ return _fs.vol ()->sectorsPerCluster ();
180180 }
181181size_t totalClusters () {
182182return _fs.vol ()->clusterCount ();
@@ -185,7 +185,7 @@ class SDFSImpl : public FSImpl
185185return (totalClusters () /blocksPerCluster ());
186186 }
187187size_t clusterSize () {
188- return blocksPerCluster () *512 ; // 512b block size
188+ return blocksPerCluster () *_fs. vol ()-> bytesPerSector ();
189189 }
190190size_t size () {
191191return (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 []>());
@@ -279,7 +279,7 @@ class SDFSFileImpl : public FileImpl
279279
280280int availableForWrite ()override
281281 {
282- return _opened ? _fd->availableForWrite () :0 ;
282+ return _opened ? _fd->availableSpaceForWrite () :0 ;
283283 }
284284
285285size_t write (const uint8_t *buf,size_t size)override
@@ -295,7 +295,6 @@ class SDFSFileImpl : public FileImpl
295295void flush ()override
296296 {
297297if (_opened) {
298- _fd->flush ();
299298 _fd->sync ();
300299 }
301300 }
@@ -375,15 +374,15 @@ class SDFSFileImpl : public FileImpl
375374
376375bool isDirectory ()const override
377376 {
378- return _opened ? _fd->isDirectory () :false ;
377+ return _opened ? _fd->isDir () :false ;
379378 }
380379
381380time_t getLastWrite ()override {
382381time_t ftime =0 ;
383382if (_opened && _fd) {
384- sdfat::dir_t tmp;
383+ sdfat::DirFat_t tmp;
385384if (_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 }
389388return ftime;
@@ -392,27 +391,25 @@ class SDFSFileImpl : public FileImpl
392391time_t getCreationTime ()override {
393392time_t ftime =0 ;
394393if (_opened && _fd) {
395- sdfat::dir_t tmp;
394+ sdfat::DirFat_t tmp;
396395if (_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 }
400399return ftime;
401400 }
402401
403-
404-
405402protected:
406403 SDFSImpl* _fs;
407- std::shared_ptr<sdfat::File > _fd;
404+ std::shared_ptr<sdfat::File32 > _fd;
408405 std::shared_ptr<char > _name;
409406bool _opened;
410407};
411408
412409class SDFSDirImpl :public DirImpl
413410{
414411public:
415- SDFSDirImpl (const String& pattern, SDFSImpl* fs, std::shared_ptr<sdfat::File > dir,const char *dirPath =nullptr )
412+ SDFSDirImpl (const String& pattern, SDFSImpl* fs, std::shared_ptr<sdfat::File32 > dir,const char *dirPath =nullptr )
416413 : _pattern(pattern), _fs(fs), _dir(dir), _valid(false ), _dirPath(nullptr )
417414 {
418415if (dirPath) {
@@ -487,17 +484,17 @@ class SDFSDirImpl : public DirImpl
487484 {
488485const int n = _pattern.length ();
489486do {
490- sdfat::File file;
487+ sdfat::File32 file;
491488 file.openNext (_dir.get (), sdfat::O_READ);
492489if (file) {
493490 _valid =1 ;
494491 _size = file.fileSize ();
495492 _isFile = file.isFile ();
496- _isDirectory = file.isDirectory ();
497- sdfat::dir_t tmp;
493+ _isDirectory = file.isDir ();
494+ sdfat::DirFat_t tmp;
498495if (file.dirEntry (&tmp)) {
499- _time =SDFSImpl::FatToTimeT (tmp.lastWriteDate , tmp.lastWriteTime );
500- _creation =SDFSImpl::FatToTimeT (tmp.creationDate , tmp.creationTime );
496+ _time =SDFSImpl::FatToTimeT (*( uint16_t *) tmp.modifyDate , *( uint16_t *) tmp.modifyTime );
497+ _creation =SDFSImpl::FatToTimeT (*( uint16_t *) tmp.createDate , *( uint16_t *) tmp.createTime );
501498}else {
502499 _time =0 ;
503500 _creation =0 ;
@@ -521,7 +518,7 @@ class SDFSDirImpl : public DirImpl
521518protected:
522519 String _pattern;
523520 SDFSImpl* _fs;
524- std::shared_ptr<sdfat::File > _dir;
521+ std::shared_ptr<sdfat::File32 > _dir;
525522bool _valid;
526523char _lfn[64 ];
527524time_t _time;