1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-21 22:50:55 +00:00

Fix all other occurences

Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
This commit is contained in:
Lukas Bachschwell 2020-09-27 13:20:14 +02:00
parent 8c0161b181
commit a6ddd48abb
Signed by: lbsadmin
GPG Key ID: CCC6AA87CC8DF425
2 changed files with 97 additions and 24 deletions

View File

@ -110,11 +110,19 @@ void listDir(const char* dirname, uint8_t levels)
void ESPUIClass::list()
{
if (!LittleFS.begin())
#if defined(ESP32)
if (!SPIFFS.begin())
{
Serial.println(F("SPIFFS Mount Failed"));
return;
}
#else
if (!LittleFS.begin())
{
Serial.println(F("LittleFS Mount Failed"));
return;
}
#endif
listDir("/", 1);
#if defined(ESP32)
@ -133,6 +141,20 @@ void ESPUIClass::list()
void deleteFile(const char* path)
{
#if defined(ESP32)
bool exists = SPIFFS.exists(path);
#else
bool exists = LittleFS.exists(path);
#endif
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
Serial.print(exists);
}
#endif
if (!exists)
{
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -152,6 +174,13 @@ void deleteFile(const char* path)
return;
}
#if defined(ESP32)
bool didRemove = SPIFFS.remove(path);
#else
bool didRemove = LittleFS.remove(path);
#endif
if (didRemove)
{
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -181,6 +210,15 @@ void deleteFile(const char* path)
void writeFile(const char* path, const char* data)
{
#if defined(ESP32)
File file = SPIFFS.open(path, FILE_WRITE);
#else
File file = LittleFS.open(path, FILE_WRITE);
#endif
if (!file)
{
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -1028,6 +1066,22 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
server = new AsyncWebServer(80);
ws = new AsyncWebSocket("/ws");
#if defined(ESP32)
bool fsBegin = SPIFFS.begin();
#else
bool fsBegin = LittleFS.begin();
#endif
if (!fsBegin)
{
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
Serial.println(F("FS Mount Failed, PLEASE CHECK THE README ON HOW TO PREPARE YOUR ESP!!!!!!!"));
}
#endif
server = new AsyncWebServer(80);
ws = new AsyncWebSocket("/ws");
if (!LittleFS.begin())
{
#if defined(DEBUG_ESPUI)
@ -1038,9 +1092,13 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
}
#endif
return;
}
#if defined(ESP32)
bool indexExists = SPIFFS.exists("/index.htm");
#else
bool indexExists = LittleFS.exists("/index.htm");
#endif
if (!indexExists)
{
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -1072,7 +1130,24 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
}
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(username, password);
}
#if defined(ESP32)
server->serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setAuthentication(username, password);
#else
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(username, password);
#endif
}
else
{
#if defined(ESP32)
server->serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm");
#else
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm");
#endif
}
// Heap for general Servertest
server->on("/heap", HTTP_GET, [](AsyncWebServerRequest *request) {
if (ESPUI.basicAuth && !request->authenticate(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword))
{
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm");
}

View File

@ -6,15 +6,13 @@
#include "Arduino.h"
#include "ArduinoJson.h"
#include "FS.h"
#include "stdlib_noniso.h"
#if defined(ESP32)
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "FS.h"
#include "LittleFS.h"
#include "SPIFFS.h"
#include "WiFi.h"
#else