File tree Expand file tree Collapse file tree 2 files changed +27
-19
lines changed Expand file tree Collapse file tree 2 files changed +27
-19
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,33 @@ extern "C" {
2020#include  < dirent.h> 
2121#include  " esp_spiffs.h" 
2222}
23+ 
2324#include  " SPIFFS.h" 
2425
2526using  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
3151bool  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()));
Original file line number Diff line number Diff line change @@ -22,18 +22,17 @@ namespace fs
2222class  SPIFFSFS  : public  FS 
2323{
2424public: 
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
3735extern  fs::SPIFFSFS SPIFFS;
3836
39- #endif  /*  _SPIFFS_H_ */ 
37+ 
38+ #endif 
                         You can’t perform that action at this time. 
           
                  
0 commit comments