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
+
1
15
extern " C" {
2
16
#include < sys/unistd.h>
3
17
#include < sys/stat.h>
@@ -13,12 +27,14 @@ SPIFFSImpl::SPIFFSImpl()
13
27
{
14
28
}
15
29
16
- bool SPIFFSImpl::exists (const char * path) {
30
+ bool SPIFFSImpl::exists (const char * path)
31
+ {
17
32
File f = open (path, " r" );
18
33
return (f == true ) && !f.isDirectory ();
19
34
}
20
35
21
- SPIFFSFS::SPIFFSFS () : FS(FSImplPtr(new SPIFFSImpl())) {
36
+ SPIFFSFS::SPIFFSFS () : FS(FSImplPtr(new SPIFFSImpl()))
37
+ {
22
38
23
39
}
24
40
@@ -62,7 +78,8 @@ void SPIFFSFS::end()
62
78
}
63
79
}
64
80
65
- bool SPIFFSFS::format () {
81
+ bool SPIFFSFS::format ()
82
+ {
66
83
disableCore0WDT ();
67
84
esp_err_t err = esp_spiffs_format (NULL );
68
85
enableCore0WDT ();
@@ -73,15 +90,17 @@ bool SPIFFSFS::format() {
73
90
return true ;
74
91
}
75
92
76
- size_t SPIFFSFS::totalBytes () {
93
+ size_t SPIFFSFS::totalBytes ()
94
+ {
77
95
size_t total,used;
78
96
if (esp_spiffs_info (NULL , &total, &used)){
79
97
return 0 ;
80
98
}
81
99
return total;
82
100
}
83
101
84
- size_t SPIFFSFS::usedBytes () {
102
+ size_t SPIFFSFS::usedBytes ()
103
+ {
85
104
size_t total,used;
86
105
if (esp_spiffs_info (NULL , &total, &used)){
87
106
return 0 ;
0 commit comments