mirror of
https://github.com/s00500/ESPUI.git
synced 2024-10-31 22:10:54 +00:00
Merge pull request #89 from bastiengrignon/feature/spiffs-update
Update filesystem
This commit is contained in:
commit
c02f357d84
@ -23,7 +23,7 @@ void listDir(const char *dirname, uint8_t levels) {
|
|||||||
Serial.printf("Listing directory: %s\n", dirname);
|
Serial.printf("Listing directory: %s\n", dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
File root = SPIFFS.open(dirname);
|
File root = LittleFS.open(dirname);
|
||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
if (ESPUI.verbosity) {
|
if (ESPUI.verbosity) {
|
||||||
@ -72,7 +72,7 @@ void listDir(const char *dirname, uint8_t levels) {
|
|||||||
Serial.printf("Listing directory: %s\n", dirname);
|
Serial.printf("Listing directory: %s\n", dirname);
|
||||||
|
|
||||||
String str = "";
|
String str = "";
|
||||||
Dir dir = SPIFFS.openDir("/");
|
Dir dir = LittleFS.openDir("/");
|
||||||
|
|
||||||
while (dir.next()) {
|
while (dir.next()) {
|
||||||
Serial.print(" FILE: ");
|
Serial.print(" FILE: ");
|
||||||
@ -85,7 +85,7 @@ void listDir(const char *dirname, uint8_t levels) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ESPUIClass::list() {
|
void ESPUIClass::list() {
|
||||||
if (!SPIFFS.begin()) {
|
if (!LittleFS.begin()) {
|
||||||
Serial.println("SPIFFS Mount Failed");
|
Serial.println("SPIFFS Mount Failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,12 +93,12 @@ void ESPUIClass::list() {
|
|||||||
listDir("/", 1);
|
listDir("/", 1);
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
|
||||||
Serial.println(SPIFFS.totalBytes());
|
Serial.println(LittleFS.totalBytes());
|
||||||
Serial.println(SPIFFS.usedBytes());
|
Serial.println(LittleFS.usedBytes());
|
||||||
|
|
||||||
#else
|
#else
|
||||||
FSInfo fs_info;
|
FSInfo fs_info;
|
||||||
SPIFFS.info(fs_info);
|
LittleFS.info(fs_info);
|
||||||
|
|
||||||
Serial.println(fs_info.totalBytes);
|
Serial.println(fs_info.totalBytes);
|
||||||
Serial.println(fs_info.usedBytes);
|
Serial.println(fs_info.usedBytes);
|
||||||
@ -108,10 +108,10 @@ void ESPUIClass::list() {
|
|||||||
|
|
||||||
void deleteFile(const char *path) {
|
void deleteFile(const char *path) {
|
||||||
if (ESPUI.verbosity) {
|
if (ESPUI.verbosity) {
|
||||||
Serial.print(SPIFFS.exists(path));
|
Serial.print(LittleFS.exists(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SPIFFS.exists(path)) {
|
if (!LittleFS.exists(path)) {
|
||||||
if (ESPUI.verbosity) {
|
if (ESPUI.verbosity) {
|
||||||
Serial.printf("File: %s does not exist, not deleting\n", path);
|
Serial.printf("File: %s does not exist, not deleting\n", path);
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ void deleteFile(const char *path) {
|
|||||||
Serial.printf("Deleting file: %s\n", path);
|
Serial.printf("Deleting file: %s\n", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SPIFFS.remove(path)) {
|
if (LittleFS.remove(path)) {
|
||||||
if (ESPUI.verbosity) {
|
if (ESPUI.verbosity) {
|
||||||
Serial.println("File deleted");
|
Serial.println("File deleted");
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ void writeFile(const char *path, const char *data) {
|
|||||||
Serial.printf("Writing file: %s\n", path);
|
Serial.printf("Writing file: %s\n", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = SPIFFS.open(path, FILE_WRITE);
|
File file = LittleFS.open(path, FILE_WRITE);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
if (ESPUI.verbosity) {
|
if (ESPUI.verbosity) {
|
||||||
@ -187,9 +187,9 @@ void ESPUIClass::prepareFileSystem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
SPIFFS.format();
|
LittleFS.format();
|
||||||
|
|
||||||
if (!SPIFFS.begin(true)) {
|
if (!LittleFS.begin(true)) {
|
||||||
if (this->verbosity) {
|
if (this->verbosity) {
|
||||||
Serial.println("SPIFFS Mount Failed");
|
Serial.println("SPIFFS Mount Failed");
|
||||||
}
|
}
|
||||||
@ -203,8 +203,8 @@ void ESPUIClass::prepareFileSystem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
SPIFFS.format();
|
LittleFS.format();
|
||||||
SPIFFS.begin();
|
LittleFS.begin();
|
||||||
|
|
||||||
if (this->verbosity) {
|
if (this->verbosity) {
|
||||||
Serial.println("SPIFFS Mount ESP8266 Done");
|
Serial.println("SPIFFS Mount ESP8266 Done");
|
||||||
@ -252,7 +252,7 @@ void ESPUIClass::prepareFileSystem() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPIFFS.end();
|
LittleFS.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Websockets Communication
|
// Handle Websockets Communication
|
||||||
@ -683,7 +683,7 @@ void ESPUIClass::beginSPIFFS(const char *_title, const char *username, const cha
|
|||||||
server = new AsyncWebServer(80);
|
server = new AsyncWebServer(80);
|
||||||
ws = new AsyncWebSocket("/ws");
|
ws = new AsyncWebSocket("/ws");
|
||||||
|
|
||||||
if (!SPIFFS.begin()) {
|
if (!LittleFS.begin()) {
|
||||||
if (ESPUI.verbosity) {
|
if (ESPUI.verbosity) {
|
||||||
Serial.println("SPIFFS Mount Failed, PLEASE CHECK THE README ON HOW TO PREPARE YOUR ESP!!!!!!!");
|
Serial.println("SPIFFS Mount Failed, PLEASE CHECK THE README ON HOW TO PREPARE YOUR ESP!!!!!!!");
|
||||||
}
|
}
|
||||||
@ -695,7 +695,7 @@ void ESPUIClass::beginSPIFFS(const char *_title, const char *username, const cha
|
|||||||
listDir("/", 1);
|
listDir("/", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SPIFFS.exists("/index.htm")) {
|
if (!LittleFS.exists("/index.htm")) {
|
||||||
if (ESPUI.verbosity) {
|
if (ESPUI.verbosity) {
|
||||||
Serial.println("Please read the README!!!!!!!, Make sure to ESPUI.prepareFileSystem() once in an empty sketch");
|
Serial.println("Please read the README!!!!!!!, Make sure to ESPUI.prepareFileSystem() once in an empty sketch");
|
||||||
}
|
}
|
||||||
@ -711,9 +711,9 @@ void ESPUIClass::beginSPIFFS(const char *_title, const char *username, const cha
|
|||||||
ws->setAuthentication(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword);
|
ws->setAuthentication(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
server->serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setAuthentication(username, password);
|
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(username, password);
|
||||||
} else {
|
} else {
|
||||||
server->serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm");
|
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heap for general Servertest
|
// Heap for general Servertest
|
||||||
|
Loading…
Reference in New Issue
Block a user