@@ -47,7 +47,7 @@ class SDFSConfig : public FSConfig
47
47
public:
48
48
static constexpr uint32_t FSId = 0x53444653 ;
49
49
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) { }
51
51
52
52
SDFSConfig setAutoFormat (bool val = true ) {
53
53
_autoFormat = val;
@@ -57,7 +57,7 @@ class SDFSConfig : public FSConfig
57
57
_csPin = pin;
58
58
return *this ;
59
59
}
60
- SDFSConfig setSPI (SPISettings spi) {
60
+ SDFSConfig setSPI (uint32_t spi) {
61
61
_spiSettings = spi;
62
62
return *this ;
63
63
}
@@ -67,9 +67,9 @@ class SDFSConfig : public FSConfig
67
67
}
68
68
69
69
// 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;
73
73
};
74
74
75
75
class SDFSImpl : public FSImpl
@@ -97,11 +97,11 @@ class SDFSImpl : public FSImpl
97
97
return false ;
98
98
}
99
99
info.maxOpenFiles = 999 ; // TODO - not valid
100
- info.blockSize = _fs.vol ()->blocksPerCluster () * 512 ;
100
+ info.blockSize = _fs.vol ()->sectorsPerCluster () * _fs. vol ()-> bytesPerSector () ;
101
101
info.pageSize = 0 ; // TODO ?
102
102
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 () );
105
105
return true ;
106
106
}
107
107
@@ -156,7 +156,7 @@ class SDFSImpl : public FSImpl
156
156
format ();
157
157
_mounted = _fs.begin (_cfg._csPin , _cfg._spiSettings );
158
158
}
159
- sdfat::SdFile::dateTimeCallback (dateTimeCB);
159
+ sdfat::FsDateTime::setCallback (dateTimeCB);
160
160
return _mounted;
161
161
}
162
162
@@ -176,7 +176,7 @@ class SDFSImpl : public FSImpl
176
176
return _fs.vol ()->fatType ();
177
177
}
178
178
size_t blocksPerCluster () {
179
- return _fs.vol ()->blocksPerCluster ();
179
+ return _fs.vol ()->sectorsPerCluster ();
180
180
}
181
181
size_t totalClusters () {
182
182
return _fs.vol ()->clusterCount ();
@@ -185,7 +185,7 @@ class SDFSImpl : public FSImpl
185
185
return (totalClusters () / blocksPerCluster ());
186
186
}
187
187
size_t clusterSize () {
188
- return blocksPerCluster () * 512 ; // 512b block size
188
+ return blocksPerCluster () * _fs. vol ()-> bytesPerSector ();
189
189
}
190
190
size_t size () {
191
191
return (clusterSize () * totalClusters ());
@@ -264,7 +264,7 @@ class SDFSImpl : public FSImpl
264
264
class SDFSFileImpl : public FileImpl
265
265
{
266
266
public:
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)
268
268
: _fs(fs), _fd(fd), _opened(true )
269
269
{
270
270
_name = std::shared_ptr<char >(new char [strlen (name) + 1 ], std::default_delete<char []>());
@@ -295,7 +295,6 @@ class SDFSFileImpl : public FileImpl
295
295
void flush () override
296
296
{
297
297
if (_opened) {
298
- _fd->flush ();
299
298
_fd->sync ();
300
299
}
301
300
}
@@ -375,15 +374,15 @@ class SDFSFileImpl : public FileImpl
375
374
376
375
bool isDirectory () const override
377
376
{
378
- return _opened ? _fd->isDirectory () : false ;
377
+ return _opened ? _fd->isDir () : false ;
379
378
}
380
379
381
380
time_t getLastWrite () override {
382
381
time_t ftime = 0 ;
383
382
if (_opened && _fd) {
384
- sdfat::dir_t tmp;
383
+ sdfat::DirFat_t tmp;
385
384
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 );
387
386
}
388
387
}
389
388
return ftime;
@@ -392,9 +391,9 @@ class SDFSFileImpl : public FileImpl
392
391
time_t getCreationTime () override {
393
392
time_t ftime = 0 ;
394
393
if (_opened && _fd) {
395
- sdfat::dir_t tmp;
394
+ sdfat::DirFat_t tmp;
396
395
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 );
398
397
}
399
398
}
400
399
return ftime;
@@ -404,15 +403,15 @@ class SDFSFileImpl : public FileImpl
404
403
405
404
protected:
406
405
SDFSImpl* _fs;
407
- std::shared_ptr<sdfat::File > _fd;
406
+ std::shared_ptr<sdfat::File32 > _fd;
408
407
std::shared_ptr<char > _name;
409
408
bool _opened;
410
409
};
411
410
412
411
class SDFSDirImpl : public DirImpl
413
412
{
414
413
public:
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 )
416
415
: _pattern(pattern), _fs(fs), _dir(dir), _valid(false ), _dirPath(nullptr )
417
416
{
418
417
if (dirPath) {
@@ -487,17 +486,17 @@ class SDFSDirImpl : public DirImpl
487
486
{
488
487
const int n = _pattern.length ();
489
488
do {
490
- sdfat::File file;
489
+ sdfat::File32 file;
491
490
file.openNext (_dir.get (), sdfat::O_READ);
492
491
if (file) {
493
492
_valid = 1 ;
494
493
_size = file.fileSize ();
495
494
_isFile = file.isFile ();
496
- _isDirectory = file.isDirectory ();
497
- sdfat::dir_t tmp;
495
+ _isDirectory = file.isDir ();
496
+ sdfat::DirFat_t tmp;
498
497
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 );
501
500
} else {
502
501
_time = 0 ;
503
502
_creation = 0 ;
@@ -521,7 +520,7 @@ class SDFSDirImpl : public DirImpl
521
520
protected:
522
521
String _pattern;
523
522
SDFSImpl* _fs;
524
- std::shared_ptr<sdfat::File > _dir;
523
+ std::shared_ptr<sdfat::File32 > _dir;
525
524
bool _valid;
526
525
char _lfn[64 ];
527
526
time_t _time;
0 commit comments