@@ -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 ()->sectorsPerCluster () * _fs. vol ()-> bytesPerSector ();
100
+ info.blockSize = _fs.vol ()->bytesPerCluster ();
101
101
info.pageSize = 0 ; // TODO ?
102
102
info.maxPathLength = 255 ; // TODO ?
103
103
info.totalBytes =_fs.vol ()->clusterCount () * info.blockSize ;
104
- info.usedBytes = info.totalBytes - (_fs.vol ()->freeClusterCount () * _fs.vol ()->sectorsPerCluster () * _fs. vol ()-> bytesPerSector ());
104
+ info.usedBytes = info.totalBytes - (_fs.vol ()->freeClusterCount () * _fs.vol ()->bytesPerCluster ());
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:: FsDateTime::setCallback (dateTimeCB);
159
+ FsDateTime::setCallback (dateTimeCB);
160
160
return _mounted;
161
161
}
162
162
@@ -185,7 +185,7 @@ class SDFSImpl : public FSImpl
185
185
return (totalClusters () / blocksPerCluster ());
186
186
}
187
187
size_t clusterSize () {
188
- return blocksPerCluster () * _fs.vol ()->bytesPerSector ();
188
+ return _fs.vol ()->bytesPerCluster ();
189
189
}
190
190
size_t size () {
191
191
return (clusterSize () * totalClusters ());
@@ -229,33 +229,33 @@ class SDFSImpl : public FSImpl
229
229
friend class SDFileImpl ;
230
230
friend class SDFSDirImpl ;
231
231
232
- sdfat::SdFat* getFs ()
233
- {
232
+ SdFat* getFs () {
234
233
return &_fs;
235
234
}
236
235
237
236
238
237
static uint8_t _getFlags (OpenMode openMode, AccessMode accessMode) {
239
238
uint8_t mode = 0 ;
240
239
if (openMode & OM_CREATE) {
241
- mode |= sdfat:: O_CREAT;
240
+ mode |= O_CREAT;
242
241
}
243
242
if (openMode & OM_APPEND) {
244
- mode |= sdfat:: O_AT_END;
243
+ mode |= O_AT_END;
245
244
}
246
245
if (openMode & OM_TRUNCATE) {
247
- mode |= sdfat::O_TRUNC;
248
- }
249
- if (accessMode & AM_READ) {
250
- mode |= sdfat::O_READ;
246
+ mode |= O_TRUNC;
251
247
}
252
- if (accessMode & AM_WRITE) {
253
- mode |= sdfat::O_WRITE;
248
+ if ((accessMode & (AM_READ | AM_WRITE)) == (AM_READ | AM_WRITE)) {
249
+ mode |= O_RDWR;
250
+ } else if (accessMode & AM_READ) {
251
+ mode |= O_READ;
252
+ } else if (accessMode & AM_WRITE) {
253
+ mode |= O_WRITE;
254
254
}
255
255
return mode;
256
256
}
257
257
258
- sdfat:: SdFat _fs;
258
+ SdFat _fs;
259
259
SDFSConfig _cfg;
260
260
bool _mounted;
261
261
};
@@ -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:: File32> fd, const char *name)
267
+ SDFSFileImpl (SDFSImpl *fs, std::shared_ptr<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 []>());
@@ -380,7 +380,7 @@ class SDFSFileImpl : public FileImpl
380
380
time_t getLastWrite () override {
381
381
time_t ftime = 0 ;
382
382
if (_opened && _fd) {
383
- sdfat:: DirFat_t tmp;
383
+ DirFat_t tmp;
384
384
if (_fd.get ()->dirEntry (&tmp)) {
385
385
ftime = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.modifyDate , *(uint16_t *)tmp.modifyTime );
386
386
}
@@ -391,7 +391,7 @@ class SDFSFileImpl : public FileImpl
391
391
time_t getCreationTime () override {
392
392
time_t ftime = 0 ;
393
393
if (_opened && _fd) {
394
- sdfat:: DirFat_t tmp;
394
+ DirFat_t tmp;
395
395
if (_fd.get ()->dirEntry (&tmp)) {
396
396
ftime = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.createDate , *(uint16_t *)tmp.createTime );
397
397
}
@@ -400,16 +400,16 @@ class SDFSFileImpl : public FileImpl
400
400
}
401
401
402
402
protected:
403
- SDFSImpl* _fs;
404
- std::shared_ptr<sdfat:: File32> _fd;
405
- std::shared_ptr<char > _name;
406
- bool _opened;
403
+ SDFSImpl* _fs;
404
+ std::shared_ptr<File32> _fd;
405
+ std::shared_ptr<char > _name;
406
+ bool _opened;
407
407
};
408
408
409
409
class SDFSDirImpl : public DirImpl
410
410
{
411
411
public:
412
- SDFSDirImpl (const String& pattern, SDFSImpl* fs, std::shared_ptr<sdfat:: File32> dir, const char *dirPath = nullptr )
412
+ SDFSDirImpl (const String& pattern, SDFSImpl* fs, std::shared_ptr<File32> dir, const char *dirPath = nullptr )
413
413
: _pattern(pattern), _fs(fs), _dir(dir), _valid(false ), _dirPath(nullptr )
414
414
{
415
415
if (dirPath) {
@@ -484,14 +484,14 @@ class SDFSDirImpl : public DirImpl
484
484
{
485
485
const int n = _pattern.length ();
486
486
do {
487
- sdfat:: File32 file;
488
- file.openNext (_dir.get (), sdfat:: O_READ);
487
+ File32 file;
488
+ file.openNext (_dir.get (), O_READ);
489
489
if (file) {
490
490
_valid = 1 ;
491
491
_size = file.fileSize ();
492
492
_isFile = file.isFile ();
493
493
_isDirectory = file.isDir ();
494
- sdfat:: DirFat_t tmp;
494
+ DirFat_t tmp;
495
495
if (file.dirEntry (&tmp)) {
496
496
_time = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.modifyDate , *(uint16_t *)tmp.modifyTime );
497
497
_creation = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.createDate , *(uint16_t *)tmp.createTime );
@@ -516,17 +516,17 @@ class SDFSDirImpl : public DirImpl
516
516
}
517
517
518
518
protected:
519
- String _pattern;
520
- SDFSImpl* _fs;
521
- std::shared_ptr<sdfat:: File32> _dir;
522
- bool _valid;
523
- char _lfn[64 ];
524
- time_t _time;
525
- time_t _creation;
526
- std::shared_ptr<char > _dirPath;
527
- uint32_t _size;
528
- bool _isFile;
529
- bool _isDirectory;
519
+ String _pattern;
520
+ SDFSImpl* _fs;
521
+ std::shared_ptr<File32> _dir;
522
+ bool _valid;
523
+ char _lfn[64 ];
524
+ time_t _time;
525
+ time_t _creation;
526
+ std::shared_ptr<char > _dirPath;
527
+ uint32_t _size;
528
+ bool _isFile;
529
+ bool _isDirectory;
530
530
};
531
531
532
532
}; // namespace sdfs
0 commit comments