mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-03 03:09:59 +00:00
Filesystem abstraction would work really well, if it wasn't for crap vendor toolchains.
This commit is contained in:
parent
4949bda606
commit
bc2cddcb11
@ -49,7 +49,9 @@ bool renameFile(const char* pathFrom, const char* pathTo)
|
|||||||
void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
|
#if (defined(ARCH_ESP32) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
|
#endif
|
||||||
File root = FSCom.open(dirname, FILE_O_READ);
|
File root = FSCom.open(dirname, FILE_O_READ);
|
||||||
if(!root){
|
if(!root){
|
||||||
return;
|
return;
|
||||||
@ -72,6 +74,16 @@ void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
|||||||
} else {
|
} else {
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
listDir(file.name(), levels -1, del);
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Removing %s\n", file.name());
|
||||||
|
strcpy(buffer, file.name());
|
||||||
|
file.close();
|
||||||
|
FSCom.rmdir(buffer);
|
||||||
|
} else {
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
listDir(file.name(), levels -1, del);
|
listDir(file.name(), levels -1, del);
|
||||||
file.close();
|
file.close();
|
||||||
@ -88,6 +100,16 @@ void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
|||||||
DEBUG_MSG(" %s (%i Bytes)\n", file.path(), file.size());
|
DEBUG_MSG(" %s (%i Bytes)\n", file.path(), file.size());
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Deleting %s\n", file.name());
|
||||||
|
strcpy(buffer, file.name());
|
||||||
|
file.close();
|
||||||
|
FSCom.remove(buffer);
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
||||||
file.close();
|
file.close();
|
||||||
@ -104,6 +126,15 @@ void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
|||||||
} else {
|
} else {
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
|
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Removing %s\n", root.name());
|
||||||
|
strcpy(buffer, root.name());
|
||||||
|
root.close();
|
||||||
|
FSCom.rmdir(buffer);
|
||||||
|
} else {
|
||||||
|
root.close();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
root.close();
|
root.close();
|
||||||
#endif
|
#endif
|
||||||
@ -113,11 +144,9 @@ void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
|||||||
void rmDir(const char * dirname)
|
void rmDir(const char * dirname)
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
#ifdef ARCH_ESP32
|
#if (defined(ARCH_ESP32) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
|
||||||
FSCom.rmdir(dirname);
|
|
||||||
listDir(dirname, 10, true);
|
listDir(dirname, 10, true);
|
||||||
#else
|
#else if defined(ARCH_NRF52)
|
||||||
// nRF52 implementation of LittleFS has a recursive delete function
|
// nRF52 implementation of LittleFS has a recursive delete function
|
||||||
FSCom.rmdir_r(dirname);
|
FSCom.rmdir_r(dirname);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user