Skip to content

Commit

Permalink
Add SPIFFS::end (esp8266#1657)
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed May 20, 2016
1 parent 43fb139 commit 5313c56
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cores/esp8266/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ bool FS::begin() {
return _impl->begin();
}

void FS::end() {
if (_impl) {
_impl->end();
}
}

bool FS::format() {
if (!_impl) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion cores/esp8266/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class FS
FS(FSImplPtr impl) : _impl(impl) { }

bool begin();

void end();

bool format();
bool info(FSInfo& info);

Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/FSImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class DirImpl {
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;
Expand Down
8 changes: 8 additions & 0 deletions cores/esp8266/spiffs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ class SPIFFSImpl : public FSImpl
return _tryMount();
}

void end() override
{
if (SPIFFS_mounted(&_fs) == 0) {
return;
}
SPIFFS_unmount(&_fs);
}

bool format() override
{
if (_size == 0) {
Expand Down
9 changes: 9 additions & 0 deletions doc/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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++
Expand Down

0 comments on commit 5313c56

Please sign in to comment.