Skip to content

Rename LITTLEFS to LittleFS to match ESP8266 #5396

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

Merged
merged 4 commits into from
Jul 16, 2021
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ set(LIBRARY_SRCS
libraries/FS/src/vfs_api.cpp
libraries/HTTPClient/src/HTTPClient.cpp
libraries/HTTPUpdate/src/HTTPUpdate.cpp
libraries/LITTLEFS/src/LITTLEFS.cpp
libraries/LittleFS/src/LittleFS.cpp
libraries/NetBIOS/src/NetBIOS.cpp
libraries/Preferences/src/Preferences.cpp
libraries/RainMaker/src/RMaker.cpp
Expand Down Expand Up @@ -140,7 +140,7 @@ set(includedirs
libraries/FS/src
libraries/HTTPClient/src
libraries/HTTPUpdate/src
libraries/LITTLEFS/src
libraries/LittleFS/src
libraries/NetBIOS/src
libraries/Preferences/src
libraries/RainMaker/src
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <Arduino.h>
#include "FS.h"
#include <LITTLEFS.h>
#include <LittleFS.h>
#include <time.h>

/* You only need to format LITTLEFS the first time you run a
/* You only need to format LittleFS the first time you run a
test or else use the LITTLEFS plugin to create a partition
https://github.com/lorol/arduino-esp32littlefs-plugin */

Expand Down Expand Up @@ -249,30 +249,30 @@ void testFileIO(fs::FS &fs, const char * path){

void setup(){
Serial.begin(115200);
if(!LITTLEFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LITTLEFS Mount Failed");
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LittleFS Mount Failed");
return;
}

listDir(LITTLEFS, "/", 0);
createDir(LITTLEFS, "/mydir");
writeFile(LITTLEFS, "/mydir/hello2.txt", "Hello2");
//writeFile(LITTLEFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
writeFile2(LITTLEFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
listDir(LITTLEFS, "/", 3);
deleteFile(LITTLEFS, "/mydir/hello2.txt");
//deleteFile(LITTLEFS, "/mydir/newdir2/newdir3/hello3.txt");
deleteFile2(LITTLEFS, "/mydir/newdir2/newdir3/hello3.txt");
removeDir(LITTLEFS, "/mydir");
listDir(LITTLEFS, "/", 3);
writeFile(LITTLEFS, "/hello.txt", "Hello ");
appendFile(LITTLEFS, "/hello.txt", "World!\r\n");
readFile(LITTLEFS, "/hello.txt");
renameFile(LITTLEFS, "/hello.txt", "/foo.txt");
readFile(LITTLEFS, "/foo.txt");
deleteFile(LITTLEFS, "/foo.txt");
testFileIO(LITTLEFS, "/test.txt");
deleteFile(LITTLEFS, "/test.txt");
listDir(LittleFS, "/", 0);
createDir(LittleFS, "/mydir");
writeFile(LittleFS, "/mydir/hello2.txt", "Hello2");
//writeFile(LittleFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
writeFile2(LittleFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
listDir(LittleFS, "/", 3);
deleteFile(LittleFS, "/mydir/hello2.txt");
//deleteFile(LittleFS, "/mydir/newdir2/newdir3/hello3.txt");
deleteFile2(LittleFS, "/mydir/newdir2/newdir3/hello3.txt");
removeDir(LittleFS, "/mydir");
listDir(LittleFS, "/", 3);
writeFile(LittleFS, "/hello.txt", "Hello ");
appendFile(LittleFS, "/hello.txt", "World!\r\n");
readFile(LittleFS, "/hello.txt");
renameFile(LittleFS, "/hello.txt", "/foo.txt");
readFile(LittleFS, "/foo.txt");
deleteFile(LittleFS, "/foo.txt");
testFileIO(LittleFS, "/test.txt");
deleteFile(LittleFS, "/test.txt");

Serial.println( "Test complete" );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <Arduino.h>
#include "FS.h"
#include <LITTLEFS.h>
#include <LittleFS.h>

/* You only need to format LITTLEFS the first time you run a
/* You only need to format LittleFS the first time you run a
test or else use the LITTLEFS plugin to create a partition
https://github.com/lorol/arduino-esp32littlefs-plugin

Expand Down Expand Up @@ -244,41 +244,41 @@ void setup(){
Serial.begin(115200);

#ifdef TWOPART
if(!LITTLEFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 5, "part2")){
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 5, "part2")){
Serial.println("part2 Mount Failed");
return;
}
appendFile(LITTLEFS, "/hello0.txt", "World0!\r\n");
readFile(LITTLEFS, "/hello0.txt");
LITTLEFS.end();
appendFile(LittleFS, "/hello0.txt", "World0!\r\n");
readFile(LittleFS, "/hello0.txt");
LittleFS.end();

Serial.println( "Done with part2, work with the first lfs partition..." );
#endif

if(!LITTLEFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LITTLEFS Mount Failed");
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LittleFS Mount Failed");
return;
}
Serial.println( "SPIFFS-like write file to new path and delete it w/folders" );
writeFile2(LITTLEFS, "/new1/new2/new3/hello3.txt", "Hello3");
listDir(LITTLEFS, "/", 3);
deleteFile2(LITTLEFS, "/new1/new2/new3/hello3.txt");
writeFile2(LittleFS, "/new1/new2/new3/hello3.txt", "Hello3");
listDir(LittleFS, "/", 3);
deleteFile2(LittleFS, "/new1/new2/new3/hello3.txt");

listDir(LITTLEFS, "/", 3);
createDir(LITTLEFS, "/mydir");
writeFile(LITTLEFS, "/mydir/hello2.txt", "Hello2");
listDir(LITTLEFS, "/", 1);
deleteFile(LITTLEFS, "/mydir/hello2.txt");
removeDir(LITTLEFS, "/mydir");
listDir(LITTLEFS, "/", 1);
writeFile(LITTLEFS, "/hello.txt", "Hello ");
appendFile(LITTLEFS, "/hello.txt", "World!\r\n");
readFile(LITTLEFS, "/hello.txt");
renameFile(LITTLEFS, "/hello.txt", "/foo.txt");
readFile(LITTLEFS, "/foo.txt");
deleteFile(LITTLEFS, "/foo.txt");
testFileIO(LITTLEFS, "/test.txt");
deleteFile(LITTLEFS, "/test.txt");
listDir(LittleFS, "/", 3);
createDir(LittleFS, "/mydir");
writeFile(LittleFS, "/mydir/hello2.txt", "Hello2");
listDir(LittleFS, "/", 1);
deleteFile(LittleFS, "/mydir/hello2.txt");
removeDir(LittleFS, "/mydir");
listDir(LittleFS, "/", 1);
writeFile(LittleFS, "/hello.txt", "Hello ");
appendFile(LittleFS, "/hello.txt", "World!\r\n");
readFile(LittleFS, "/hello.txt");
renameFile(LittleFS, "/hello.txt", "/foo.txt");
readFile(LittleFS, "/foo.txt");
deleteFile(LittleFS, "/foo.txt");
testFileIO(LittleFS, "/test.txt");
deleteFile(LittleFS, "/test.txt");

Serial.println( "Test complete" );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "FS.h"
//#include "SPIFFS.h"
#include "LITTLEFS.h"
#include "LittleFS.h"
#include <time.h>
#include <WiFi.h>

#define SPIFFS LITTLEFS
#define SPIFFS LittleFS

/* This examples uses "quick re-define" of SPIFFS to run
an existing sketch with LITTLEFS instead of SPIFFS
an existing sketch with LittleFS instead of SPIFFS

You only need to format LITTLEFS the first time you run a
test or else use the LITTLEFS plugin to create a partition
You only need to format LittleFS the first time you run a
test or else use the LittleFS plugin to create a partition
https://github.com/lorol/arduino-esp32littlefs-plugin */

#define FORMAT_LITTLEFS_IF_FAILED true
Expand Down Expand Up @@ -169,7 +169,7 @@ void setup(){
Serial.println("");

if(!SPIFFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LITTLEFS Mount Failed");
Serial.println("LittleFS Mount Failed");
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name=LITTLEFS
name=LittleFS
version=2.0.0
author=
maintainer=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
#include <dirent.h>
}
#include "sdkconfig.h"
#include "LITTLEFS.h"
#include "LittleFS.h"

#ifdef CONFIG_LITTLEFS_PAGE_SIZE
extern "C" {
Expand All @@ -31,37 +31,37 @@ extern "C" {

using namespace fs;

class LITTLEFSImpl : public VFSImpl
class LittleFSImpl : public VFSImpl
{
public:
LITTLEFSImpl();
virtual ~LITTLEFSImpl() { }
LittleFSImpl();
virtual ~LittleFSImpl() { }
virtual bool exists(const char* path);
};

LITTLEFSImpl::LITTLEFSImpl()
LittleFSImpl::LittleFSImpl()
{
}

bool LITTLEFSImpl::exists(const char* path)
bool LittleFSImpl::exists(const char* path)
{
File f = open(path, "r");
return (f == true);
}

LITTLEFSFS::LITTLEFSFS() : FS(FSImplPtr(new LITTLEFSImpl())), partitionLabel_(NULL)
LittleFSFS::LittleFSFS() : FS(FSImplPtr(new LittleFSImpl())), partitionLabel_(NULL)
{
}

LITTLEFSFS::~LITTLEFSFS()
LittleFSFS::~LittleFSFS()
{
if (partitionLabel_){
free(partitionLabel_);
partitionLabel_ = NULL;
}
}

bool LITTLEFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFiles, const char * partitionLabel)
bool LittleFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFiles, const char * partitionLabel)
{

if (partitionLabel_){
Expand All @@ -74,7 +74,7 @@ bool LITTLEFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpen
}

if(esp_littlefs_mounted(partitionLabel_)){
log_w("LITTLEFS Already Mounted!");
log_w("LittleFS Already Mounted!");
return true;
}

Expand All @@ -91,38 +91,38 @@ bool LITTLEFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpen
}
}
if(err != ESP_OK){
log_e("Mounting LITTLEFS failed! Error: %d", err);
log_e("Mounting LittleFS failed! Error: %d", err);
return false;
}
_impl->mountpoint(basePath);
return true;
}

void LITTLEFSFS::end()
void LittleFSFS::end()
{
if(esp_littlefs_mounted(partitionLabel_)){
esp_err_t err = esp_vfs_littlefs_unregister(partitionLabel_);
if(err){
log_e("Unmounting LITTLEFS failed! Error: %d", err);
log_e("Unmounting LittleFS failed! Error: %d", err);
return;
}
_impl->mountpoint(NULL);
}
}

bool LITTLEFSFS::format()
bool LittleFSFS::format()
{
disableCore0WDT();
esp_err_t err = esp_littlefs_format(partitionLabel_);
enableCore0WDT();
if(err){
log_e("Formatting LITTLEFS failed! Error: %d", err);
log_e("Formatting LittleFS failed! Error: %d", err);
return false;
}
return true;
}

size_t LITTLEFSFS::totalBytes()
size_t LittleFSFS::totalBytes()
{
size_t total,used;
if(esp_littlefs_info(partitionLabel_, &total, &used)){
Expand All @@ -131,7 +131,7 @@ size_t LITTLEFSFS::totalBytes()
return total;
}

size_t LITTLEFSFS::usedBytes()
size_t LittleFSFS::usedBytes()
{
size_t total,used;
if(esp_littlefs_info(partitionLabel_, &total, &used)){
Expand All @@ -140,5 +140,5 @@ size_t LITTLEFSFS::usedBytes()
return used;
}

LITTLEFSFS LITTLEFS;
LittleFSFS LittleFS;
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
namespace fs
{

class LITTLEFSFS : public FS
class LittleFSFS : public FS
{
public:
LITTLEFSFS();
~LITTLEFSFS();
LittleFSFS();
~LittleFSFS();
bool begin(bool formatOnFail=false, const char * basePath="/littlefs", uint8_t maxOpenFiles=10, const char * partitionLabel="spiffs");
bool format();
size_t totalBytes();
Expand All @@ -36,7 +36,7 @@ class LITTLEFSFS : public FS

}

extern fs::LITTLEFSFS LITTLEFS;
extern fs::LittleFSFS LittleFS;


#endif