Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2750 #2763

Merged
merged 5 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions libraries/SPIFFS/src/SPIFFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,33 @@ extern "C" {
#include <dirent.h>
#include "esp_spiffs.h"
}

#include "SPIFFS.h"

using namespace fs;

SPIFFSFS::SPIFFSFS(FSImplPtr impl)
: FS(impl)
{}
class SPIFFSImpl : public VFSImpl
{
public:
SPIFFSImpl();
virtual ~SPIFFSImpl() { }
virtual bool exists(const char* path);
};

SPIFFSImpl::SPIFFSImpl()
{
}

bool SPIFFSImpl::exists(const char* path)
{
File f = open(path, "r");
return (f == true) && !f.isDirectory();
}

SPIFFSFS::SPIFFSFS() : FS(FSImplPtr(new SPIFFSImpl()))
{

}

bool SPIFFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFiles)
{
Expand Down Expand Up @@ -98,16 +118,5 @@ size_t SPIFFSFS::usedBytes()
return used;
}

bool SPIFFSFS::exists(const char* path)
{
File f = open(path, "r");
return (f == true) && !f.isDirectory();
}

bool SPIFFSFS::exists(const String& path)
{
return exists(path.c_str());
}

SPIFFSFS SPIFFS;

SPIFFSFS SPIFFS = SPIFFSFS(FSImplPtr(new VFSImpl()));
7 changes: 3 additions & 4 deletions libraries/SPIFFS/src/SPIFFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ namespace fs
class SPIFFSFS : public FS
{
public:
SPIFFSFS(FSImplPtr impl);
SPIFFSFS();
bool begin(bool formatOnFail=false, const char * basePath="/spiffs", uint8_t maxOpenFiles=10);
bool format();
size_t totalBytes();
size_t usedBytes();
void end();
bool exists(const char* path);
bool exists(const String& path);
};

}

extern fs::SPIFFSFS SPIFFS;

#endif /* _SPIFFS_H_ */

#endif