wie macht man eien Ueberpruefung ob ein Filesystem gemounte ist oder nicht?
Aktuell ueberpruefe ich mit (!LittleFS.begin()) vor einer Dateioperation ob das Filesystem gemounted ist. ISt dies der richtige Weg? oder we macht man das richtig?
hier mein Sketch
#include "LittleFS.h"
//function prototypes
void readData();
void writeData(String data);
void deleteData();
void setup() {
//Start the serial monitor
Serial.begin(115200);
//Start LittleFS
if(!LittleFS.begin()){
Serial.println("An Error has occurred while mounting LittleFS");
return;
}
//Read the saved data
readData();
}
void loop() {
}
void readData()
{
//Open the file
if(!LittleFS.begin()){
File file = LittleFS.open("/SavedFile.txt", "r");
//Check if the file exists
if(!file){
//Read the file data and display it on LCD
Serial.println("No Saved Data!");
return;
}
//Close the file
file.close();
}
}
This method mounts file system. It must be called before any other FS APIs are used. Returns true if file system was mounted successfully, false otherwise. With no options it will format SPIFFS if it is unable to mount it on the first try.