Add remove SD files for Mini

This commit is contained in:
Just Call Me Koko
2024-02-20 15:40:52 -05:00
parent a10434329a
commit 58c93ed401
5 changed files with 124 additions and 13 deletions

View File

@@ -79,6 +79,10 @@ bool SDInterface::initSD() {
SD.mkdir("/SCRIPTS");
Serial.println("/SCRIPTS created");
}
this->sd_files = new LinkedList<String>();
this->sd_files->add("Back");
return true;
}
@@ -98,6 +102,13 @@ File SDInterface::getFile(String path) {
}
}
bool SDInterface::removeFile(String file_path) {
if (SD.remove(file_path))
return true;
else
return false;
}
void SDInterface::listDirToLinkedList(LinkedList<String>* file_names, String str_dir, String ext) {
if (this->supported) {
File dir = SD.open(str_dir);
@@ -108,12 +119,18 @@ void SDInterface::listDirToLinkedList(LinkedList<String>* file_names, String str
{
break;
}
if (entry.isDirectory())
continue;
String file_name = entry.name();
if (ext != "") {
String file_name = entry.name();
if (file_name.endsWith(ext)) {
file_names->add(file_name);
}
}
else
file_names->add(file_name);
}
}
}