SPIFFS Remove first four files of eight in array
Posted: Sun Jul 14, 2019 2:49 pm
Trying to get list of filenames with index number of filename. Will remove filename based on index number to retrieve filename from array. First four filenames will be removed -- out of eight files listed with first, four characters "/LOG."
Plan to use in a function to be called when index number reaches eight, to remove files.
First time working with arrays. Having problem getting filename into array and adding index number.
Code compiles. Requesting help solving core panic.
William
Four files hold about one month of data; plan to retain a month of data always on web server.
William
Plan to use in a function to be called when index number reaches eight, to remove files.
Code: Select all
#include "SPIFFS.h"
char* filelist[12][8];
char i;
char j;
void setup() {
Serial.begin(115200);
if (!SPIFFS.begin(true)) { //Dev board is a ESP32
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
File root = SPIFFS.open("/");
File file = root.openNextFile();
while(file)
{
if(strncmp(file.name(), "/LOG", 4) == 0)
{
j++;
strcpy(filelist[i][j], file.name());
Serial.print(filelist[i][j]);
Serial.print(" " + j);
}
file = root.openNextFile();
}
for(j = 0;j < 4; j++) //Delete only first four files; keep from getting too many log files.
{
SPIFFS.remove(filelist[i][j]);
Serial.print("Removed: ");
Serial.println(filelist[i][j]);
}
}
void loop() {}
First time working with arrays. Having problem getting filename into array and adding index number.
Code compiles. Requesting help solving core panic.
William
Four files hold about one month of data; plan to retain a month of data always on web server.
William