1
- // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include " vfs_api.h"
16
-
17
1
extern " C" {
18
2
#include < sys/unistd.h>
19
3
#include < sys/stat.h>
20
4
#include < dirent.h>
21
5
#include " esp_spiffs.h"
22
6
}
7
+
23
8
#include " SPIFFS.h"
24
9
25
10
using namespace fs ;
26
11
27
- SPIFFSFS::SPIFFSFS (FSImplPtr impl)
28
- : FS(impl)
29
- {}
12
+ SPIFFSImpl::SPIFFSImpl ()
13
+ {
14
+ }
15
+
16
+ bool SPIFFSImpl::exists (const char * path) {
17
+ File f = open (path, " r" );
18
+ return (f == true ) && !f.isDirectory ();
19
+ }
20
+
21
+ SPIFFSFS::SPIFFSFS () : FS(FSImplPtr(new SPIFFSImpl())) {
22
+
23
+ }
30
24
31
25
bool SPIFFSFS::begin (bool formatOnFail, const char * basePath, uint8_t maxOpenFiles)
32
26
{
@@ -68,8 +62,7 @@ void SPIFFSFS::end()
68
62
}
69
63
}
70
64
71
- bool SPIFFSFS::format ()
72
- {
65
+ bool SPIFFSFS::format () {
73
66
disableCore0WDT ();
74
67
esp_err_t err = esp_spiffs_format (NULL );
75
68
enableCore0WDT ();
@@ -80,34 +73,21 @@ bool SPIFFSFS::format()
80
73
return true ;
81
74
}
82
75
83
- size_t SPIFFSFS::totalBytes ()
84
- {
76
+ size_t SPIFFSFS::totalBytes () {
85
77
size_t total,used;
86
78
if (esp_spiffs_info (NULL , &total, &used)){
87
79
return 0 ;
88
80
}
89
81
return total;
90
82
}
91
83
92
- size_t SPIFFSFS::usedBytes ()
93
- {
84
+ size_t SPIFFSFS::usedBytes () {
94
85
size_t total,used;
95
86
if (esp_spiffs_info (NULL , &total, &used)){
96
87
return 0 ;
97
88
}
98
89
return used;
99
90
}
100
91
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
-
92
+ SPIFFSFS SPIFFS;
112
93
113
- SPIFFSFS SPIFFS = SPIFFSFS(FSImplPtr(new VFSImpl()));
0 commit comments