Skip to content

Commit fd5a2f0

Browse files
judge2005me-no-dev
authored andcommitted
Fix #2750 (#2763)
* Fix #2750 * Fixes for pull comments * latest modifications following comments from me-no-dev * Move SPIFFSFSImpl to .cpp file
1 parent e9389e3 commit fd5a2f0

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

libraries/SPIFFS/src/SPIFFS.cpp

+24-15
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,33 @@ extern "C" {
2020
#include <dirent.h>
2121
#include "esp_spiffs.h"
2222
}
23+
2324
#include "SPIFFS.h"
2425

2526
using namespace fs;
2627

27-
SPIFFSFS::SPIFFSFS(FSImplPtr impl)
28-
: FS(impl)
29-
{}
28+
class SPIFFSImpl : public VFSImpl
29+
{
30+
public:
31+
SPIFFSImpl();
32+
virtual ~SPIFFSImpl() { }
33+
virtual bool exists(const char* path);
34+
};
35+
36+
SPIFFSImpl::SPIFFSImpl()
37+
{
38+
}
39+
40+
bool SPIFFSImpl::exists(const char* path)
41+
{
42+
File f = open(path, "r");
43+
return (f == true) && !f.isDirectory();
44+
}
45+
46+
SPIFFSFS::SPIFFSFS() : FS(FSImplPtr(new SPIFFSImpl()))
47+
{
48+
49+
}
3050

3151
bool SPIFFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFiles)
3252
{
@@ -98,16 +118,5 @@ size_t SPIFFSFS::usedBytes()
98118
return used;
99119
}
100120

101-
bool SPIFFSFS::exists(const char* path)
102-
{
103-
File f = open(path, "r");
104-
return (f == true) && !f.isDirectory();
105-
}
106-
107-
bool SPIFFSFS::exists(const String& path)
108-
{
109-
return exists(path.c_str());
110-
}
111-
121+
SPIFFSFS SPIFFS;
112122

113-
SPIFFSFS SPIFFS = SPIFFSFS(FSImplPtr(new VFSImpl()));

libraries/SPIFFS/src/SPIFFS.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@ namespace fs
2222
class SPIFFSFS : public FS
2323
{
2424
public:
25-
SPIFFSFS(FSImplPtr impl);
25+
SPIFFSFS();
2626
bool begin(bool formatOnFail=false, const char * basePath="/spiffs", uint8_t maxOpenFiles=10);
2727
bool format();
2828
size_t totalBytes();
2929
size_t usedBytes();
3030
void end();
31-
bool exists(const char* path);
32-
bool exists(const String& path);
3331
};
3432

3533
}
3634

3735
extern fs::SPIFFSFS SPIFFS;
3836

39-
#endif /* _SPIFFS_H_ */
37+
38+
#endif

0 commit comments

Comments
 (0)