File tree Expand file tree Collapse file tree 5 files changed +26
-1
lines changed Expand file tree Collapse file tree 5 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,12 @@ bool FS::begin() {
167167 return _impl->begin ();
168168}
169169
170+ void FS::end () {
171+ if (_impl) {
172+ _impl->end ();
173+ }
174+ }
175+
170176bool FS::format () {
171177 if (!_impl) {
172178 return false ;
Original file line number Diff line number Diff line change @@ -102,7 +102,8 @@ class FS
102102 FS (FSImplPtr impl) : _impl(impl) { }
103103
104104 bool begin ();
105-
105+ void end ();
106+
106107 bool format ();
107108 bool info (FSInfo& info);
108109
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ class DirImpl {
6363class FSImpl {
6464public:
6565 virtual bool begin () = 0;
66+ virtual void end () = 0;
6667 virtual bool format () = 0;
6768 virtual bool info (FSInfo& info) = 0;
6869 virtual FileImplPtr open (const char * path, OpenMode openMode, AccessMode accessMode) = 0;
Original file line number Diff line number Diff line change @@ -132,6 +132,14 @@ class SPIFFSImpl : public FSImpl
132132 return _tryMount ();
133133 }
134134
135+ void end () override
136+ {
137+ if (SPIFFS_mounted (&_fs) == 0 ) {
138+ return ;
139+ }
140+ SPIFFS_unmount (&_fs);
141+ }
142+
135143 bool format () override
136144 {
137145 if (_size == 0 ) {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ title: File System
77 * [ Uploading files to file system] ( #uploading-files-to-file-system )
88 * [ File system object (SPIFFS)] ( #file-system-object-spiffs )
99 * [ begin] ( #begin )
10+ * [ end] ( #end )
1011 * [ format] ( #format )
1112 * [ open] ( #open )
1213 * [ exists] ( #exists )
@@ -86,6 +87,14 @@ This method mounts SPIFFS file system. It must be called before any other
8687FS APIs are used. Returns * true* if file system was mounted successfully, false
8788otherwise.
8889
90+ ### end
91+
92+ ``` c++
93+ SPIFFS.end()
94+ ```
95+
96+ This method unmounts SPIFFS file system. Use this method before updating SPIFFS using OTA.
97+
8998### format
9099
91100``` c++
You can’t perform that action at this time.
0 commit comments