@@ -97,11 +97,11 @@ class SDFSImpl : public FSImpl
9797 return false ;
9898 }
9999 info.maxOpenFiles = 999 ; // TODO - not valid
100- info.blockSize = _fs.vol ()->sectorsPerCluster () * _fs. vol ()-> bytesPerSector ();
100+ info.blockSize = _fs.vol ()->bytesPerCluster ();
101101 info.pageSize = 0 ; // TODO ?
102102 info.maxPathLength = 255 ; // TODO ?
103103 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 ());
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:: FsDateTime::setCallback (dateTimeCB);
159+ FsDateTime::setCallback (dateTimeCB);
160160 return _mounted;
161161 }
162162
@@ -185,7 +185,7 @@ class SDFSImpl : public FSImpl
185185 return (totalClusters () / blocksPerCluster ());
186186 }
187187 size_t clusterSize () {
188- return blocksPerCluster () * _fs.vol ()->bytesPerSector ();
188+ return _fs.vol ()->bytesPerCluster ();
189189 }
190190 size_t size () {
191191 return (clusterSize () * totalClusters ());
@@ -229,33 +229,33 @@ class SDFSImpl : public FSImpl
229229 friend class SDFileImpl ;
230230 friend class SDFSDirImpl ;
231231
232- sdfat::SdFat* getFs ()
233- {
232+ SdFat* getFs () {
234233 return &_fs;
235234 }
236235
237236
238237 static uint8_t _getFlags (OpenMode openMode, AccessMode accessMode) {
239238 uint8_t mode = 0 ;
240239 if (openMode & OM_CREATE) {
241- mode |= sdfat:: O_CREAT;
240+ mode |= O_CREAT;
242241 }
243242 if (openMode & OM_APPEND) {
244- mode |= sdfat:: O_AT_END;
243+ mode |= O_AT_END;
245244 }
246245 if (openMode & OM_TRUNCATE) {
247- mode |= sdfat::O_TRUNC;
248- }
249- if (accessMode & AM_READ) {
250- mode |= sdfat::O_READ;
246+ mode |= O_TRUNC;
251247 }
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;
254254 }
255255 return mode;
256256 }
257257
258- sdfat:: SdFat _fs;
258+ SdFat _fs;
259259 SDFSConfig _cfg;
260260 bool _mounted;
261261};
@@ -264,7 +264,7 @@ class SDFSImpl : public FSImpl
264264class SDFSFileImpl : public FileImpl
265265{
266266public:
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)
268268 : _fs(fs), _fd(fd), _opened(true )
269269 {
270270 _name = std::shared_ptr<char >(new char [strlen (name) + 1 ], std::default_delete<char []>());
@@ -380,7 +380,7 @@ class SDFSFileImpl : public FileImpl
380380 time_t getLastWrite () override {
381381 time_t ftime = 0 ;
382382 if (_opened && _fd) {
383- sdfat:: DirFat_t tmp;
383+ DirFat_t tmp;
384384 if (_fd.get ()->dirEntry (&tmp)) {
385385 ftime = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.modifyDate , *(uint16_t *)tmp.modifyTime );
386386 }
@@ -391,7 +391,7 @@ class SDFSFileImpl : public FileImpl
391391 time_t getCreationTime () override {
392392 time_t ftime = 0 ;
393393 if (_opened && _fd) {
394- sdfat:: DirFat_t tmp;
394+ DirFat_t tmp;
395395 if (_fd.get ()->dirEntry (&tmp)) {
396396 ftime = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.createDate , *(uint16_t *)tmp.createTime );
397397 }
@@ -400,16 +400,16 @@ class SDFSFileImpl : public FileImpl
400400 }
401401
402402protected:
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;
407407};
408408
409409class SDFSDirImpl : public DirImpl
410410{
411411public:
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 )
413413 : _pattern(pattern), _fs(fs), _dir(dir), _valid(false ), _dirPath(nullptr )
414414 {
415415 if (dirPath) {
@@ -484,14 +484,14 @@ class SDFSDirImpl : public DirImpl
484484 {
485485 const int n = _pattern.length ();
486486 do {
487- sdfat:: File32 file;
488- file.openNext (_dir.get (), sdfat:: O_READ);
487+ File32 file;
488+ file.openNext (_dir.get (), O_READ);
489489 if (file) {
490490 _valid = 1 ;
491491 _size = file.fileSize ();
492492 _isFile = file.isFile ();
493493 _isDirectory = file.isDir ();
494- sdfat:: DirFat_t tmp;
494+ DirFat_t tmp;
495495 if (file.dirEntry (&tmp)) {
496496 _time = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.modifyDate , *(uint16_t *)tmp.modifyTime );
497497 _creation = SDFSImpl::FatToTimeT (*(uint16_t *)tmp.createDate , *(uint16_t *)tmp.createTime );
@@ -516,17 +516,17 @@ class SDFSDirImpl : public DirImpl
516516 }
517517
518518protected:
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;
530530};
531531
532532}; // namespace sdfs
0 commit comments