1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Add SPIFFS::end (#1657)

This commit is contained in:
Ivan Grokhotkov 2016-05-20 10:20:04 +08:00
parent 43fb139ed8
commit 5313c56f24
5 changed files with 26 additions and 1 deletions

View File

@ -167,6 +167,12 @@ bool FS::begin() {
return _impl->begin();
}
void FS::end() {
if (_impl) {
_impl->end();
}
}
bool FS::format() {
if (!_impl) {
return false;

View File

@ -102,6 +102,7 @@ public:
FS(FSImplPtr impl) : _impl(impl) { }
bool begin();
void end();
bool format();
bool info(FSInfo& info);

View File

@ -63,6 +63,7 @@ public:
class FSImpl {
public:
virtual bool begin() = 0;
virtual void end() = 0;
virtual bool format() = 0;
virtual bool info(FSInfo& info) = 0;
virtual FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) = 0;

View File

@ -132,6 +132,14 @@ public:
return _tryMount();
}
void end() override
{
if (SPIFFS_mounted(&_fs) == 0) {
return;
}
SPIFFS_unmount(&_fs);
}
bool format() override
{
if (_size == 0) {

View File

@ -7,6 +7,7 @@ title: File System
* [Uploading files to file system](#uploading-files-to-file-system)
* [File system object (SPIFFS)](#file-system-object-spiffs)
* [begin](#begin)
* [end](#end)
* [format](#format)
* [open](#open)
* [exists](#exists)
@ -86,6 +87,14 @@ This method mounts SPIFFS file system. It must be called before any other
FS APIs are used. Returns *true* if file system was mounted successfully, false
otherwise.
### end
```c++
SPIFFS.end()
```
This method unmounts SPIFFS file system. Use this method before updating SPIFFS using OTA.
### format
```c++