Skip to content

Commit 617206d

Browse files
author
Me No Dev
committed
Merge remote-tracking branch 'esp8266/master'
2 parents c130c17 + 5313c56 commit 617206d

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

cores/esp8266/FS.cpp

+6
Original file line numberDiff line numberDiff 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+
170176
bool FS::format() {
171177
if (!_impl) {
172178
return false;

cores/esp8266/FS.h

+5-2
Original file line numberDiff line numberDiff 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

@@ -127,6 +128,7 @@ class FS
127128

128129
} // namespace fs
129130

131+
#ifndef FS_NO_GLOBALS
130132
using fs::FS;
131133
using fs::File;
132134
using fs::Dir;
@@ -135,7 +137,8 @@ using fs::SeekSet;
135137
using fs::SeekCur;
136138
using fs::SeekEnd;
137139
using fs::FSInfo;
140+
#endif //FS_NO_GLOBALS
138141

139-
extern FS SPIFFS;
142+
extern fs::FS SPIFFS;
140143

141144
#endif //FS_H

cores/esp8266/FSImpl.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class DirImpl {
6363
class FSImpl {
6464
public:
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;

cores/esp8266/spiffs_api.h

+8
Original file line numberDiff line numberDiff 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) {

doc/filesystem.md

+9
Original file line numberDiff line numberDiff 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
8687
FS APIs are used. Returns *true* if file system was mounted successfully, false
8788
otherwise.
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++

0 commit comments

Comments
 (0)