29
29
*/
30
30
#include < limits>
31
31
#include < assert.h>
32
- #include " FS.h"
33
- #include " FSImpl.h"
32
+ #include < FSImpl.h>
34
33
#include " debug.h"
35
34
#include < SPI.h>
36
35
#include < SdFat.h>
37
36
#include < FS.h>
38
37
39
- using namespace fs ;
40
-
41
38
namespace sdfs {
42
39
43
40
class SDFSFileImpl ;
44
41
class SDFSDirImpl ;
45
- class SDFSConfig : public FSConfig
42
+ class SDFSConfig : public fs :: FSConfig
46
43
{
47
44
public:
48
45
static constexpr uint32_t FSId = 0x53444653 ;
@@ -72,26 +69,26 @@ class SDFSConfig : public FSConfig
72
69
uint32_t _spiSettings;
73
70
};
74
71
75
- class SDFSImpl : public FSImpl
72
+ class SDFSImpl : public fs :: FSImpl
76
73
{
77
74
public:
78
75
SDFSImpl () : _mounted(false )
79
76
{
80
77
}
81
78
82
- FileImplPtr open (const char * path, OpenMode openMode, AccessMode accessMode) override ;
79
+ fs:: FileImplPtr open (const char * path, fs:: OpenMode openMode, fs:: AccessMode accessMode) override ;
83
80
84
81
bool exists (const char * path) override {
85
82
return _mounted ? _fs.exists (path) : false ;
86
83
}
87
84
88
- DirImplPtr openDir (const char * path) override ;
85
+ fs:: DirImplPtr openDir (const char * path) override ;
89
86
90
87
bool rename (const char * pathFrom, const char * pathTo) override {
91
88
return _mounted ? _fs.rename (pathFrom, pathTo) : false ;
92
89
}
93
90
94
- bool info64 (FSInfo64& info) override {
91
+ bool info64 (fs:: FSInfo64& info) override {
95
92
if (!_mounted) {
96
93
DEBUGV (" SDFS::info: FS not mounted\n " );
97
94
return false ;
@@ -105,8 +102,8 @@ class SDFSImpl : public FSImpl
105
102
return true ;
106
103
}
107
104
108
- bool info (FSInfo& info) override {
109
- FSInfo64 i;
105
+ bool info (fs:: FSInfo& info) override {
106
+ fs:: FSInfo64 i;
110
107
if (!info64 (i)) {
111
108
return false ;
112
109
}
@@ -137,7 +134,7 @@ class SDFSImpl : public FSImpl
137
134
return _mounted ?_fs.rmdir (path) : false ;
138
135
}
139
136
140
- bool setConfig (const FSConfig &cfg) override
137
+ bool setConfig (const fs:: FSConfig &cfg) override
141
138
{
142
139
if ((cfg._type != SDFSConfig::FSId) || _mounted) {
143
140
DEBUGV (" SDFS::setConfig: invalid config or already mounted\n " );
@@ -234,22 +231,22 @@ class SDFSImpl : public FSImpl
234
231
}
235
232
236
233
237
- static uint8_t _getFlags (OpenMode openMode, AccessMode accessMode) {
234
+ static uint8_t _getFlags (fs:: OpenMode openMode, fs:: AccessMode accessMode) {
238
235
uint8_t mode = 0 ;
239
- if (openMode & OM_CREATE) {
236
+ if (openMode & fs:: OM_CREATE) {
240
237
mode |= O_CREAT;
241
238
}
242
- if (openMode & OM_APPEND) {
239
+ if (openMode & fs:: OM_APPEND) {
243
240
mode |= O_AT_END;
244
241
}
245
- if (openMode & OM_TRUNCATE) {
242
+ if (openMode & fs:: OM_TRUNCATE) {
246
243
mode |= O_TRUNC;
247
244
}
248
- if ((accessMode & (AM_READ | AM_WRITE)) == (AM_READ | AM_WRITE)) {
245
+ if ((accessMode & (fs:: AM_READ | fs:: AM_WRITE)) == (fs:: AM_READ | fs:: AM_WRITE)) {
249
246
mode |= O_RDWR;
250
- } else if (accessMode & AM_READ) {
247
+ } else if (accessMode & fs:: AM_READ) {
251
248
mode |= O_READ;
252
- } else if (accessMode & AM_WRITE) {
249
+ } else if (accessMode & fs:: AM_WRITE) {
253
250
mode |= O_WRITE;
254
251
}
255
252
return mode;
@@ -261,7 +258,7 @@ class SDFSImpl : public FSImpl
261
258
};
262
259
263
260
264
- class SDFSFileImpl : public FileImpl
261
+ class SDFSFileImpl : public fs :: FileImpl
265
262
{
266
263
public:
267
264
SDFSFileImpl (SDFSImpl *fs, std::shared_ptr<File32> fd, const char *name)
@@ -299,22 +296,22 @@ class SDFSFileImpl : public FileImpl
299
296
}
300
297
}
301
298
302
- bool seek (uint32_t pos, SeekMode mode) override
299
+ bool seek (uint32_t pos, fs:: SeekMode mode) override
303
300
{
304
301
if (!_opened) {
305
302
return false ;
306
303
}
307
304
switch (mode) {
308
- case SeekSet:
305
+ case fs:: SeekSet:
309
306
return _fd->seekSet (pos);
310
- case SeekEnd:
307
+ case fs:: SeekEnd:
311
308
return _fd->seekEnd (-pos); // TODO again, odd from POSIX
312
- case SeekCur:
309
+ case fs:: SeekCur:
313
310
return _fd->seekCur (pos);
314
311
default :
315
312
// Should not be hit, we've got an invalid seek mode
316
313
DEBUGV (" SDFSFileImpl::seek: invalid seek mode %d\n " , mode);
317
- assert ((mode==SeekSet) || (mode==SeekEnd) || (mode==SeekCur)); // Will fail and give meaningful assert message
314
+ assert ((mode==fs:: SeekSet) || (mode==fs:: SeekEnd) || (mode==fs:: SeekCur)); // Will fail and give meaningful assert message
318
315
return false ;
319
316
}
320
317
}
@@ -406,7 +403,7 @@ class SDFSFileImpl : public FileImpl
406
403
bool _opened;
407
404
};
408
405
409
- class SDFSDirImpl : public DirImpl
406
+ class SDFSDirImpl : public fs :: DirImpl
410
407
{
411
408
public:
412
409
SDFSDirImpl (const String& pattern, SDFSImpl* fs, std::shared_ptr<File32> dir, const char *dirPath = nullptr )
@@ -423,10 +420,10 @@ class SDFSDirImpl : public DirImpl
423
420
_dir->close ();
424
421
}
425
422
426
- FileImplPtr openFile (OpenMode openMode, AccessMode accessMode) override
423
+ fs:: FileImplPtr openFile (fs:: OpenMode openMode, fs:: AccessMode accessMode) override
427
424
{
428
425
if (!_valid) {
429
- return FileImplPtr ();
426
+ return fs:: FileImplPtr ();
430
427
}
431
428
// MAX_PATH on FAT32 is potentially 260 bytes per most implementations
432
429
char tmpName[260 ];
@@ -532,7 +529,7 @@ class SDFSDirImpl : public DirImpl
532
529
}; // namespace sdfs
533
530
534
531
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SDFS)
535
- extern FS SDFS;
532
+ extern fs:: FS SDFS;
536
533
using sdfs::SDFSConfig;
537
534
#endif
538
535
0 commit comments