Files
IoTManager/src/FileSystem.cpp

36 lines
1.3 KiB
C++
Raw Normal View History

2020-12-18 23:52:35 +01:00
#include "FileSystem.h"
#include "Global.h"
void getFSInfo() {
// Информация о ФС
2020-12-19 13:31:38 +01:00
2020-12-18 23:52:35 +01:00
FSInfo buf;
2020-12-19 13:31:38 +01:00
if (getInfo(buf)) {
SerialPrint("I", F("FS"), F("Get FS info completed"));
size_t totalBytes = buf.totalBytes; // всего
size_t usedBytes = buf.usedBytes; // использовано
size_t maxOpenFiles = buf.maxOpenFiles; // лимит на открые файлы
size_t maxPathLength = buf.maxPathLength; // лимит на пути и имена файлов
size_t freeBytes = totalBytes - usedBytes;
2020-12-19 13:39:04 +01:00
float freePer = ((float) freeBytes / totalBytes) * 100;
2020-12-19 13:31:38 +01:00
jsonWriteStr(configSetupJson, F("freeBytes"), String(freePer) + "% (" + String(freeBytes) + ")");
2020-12-18 23:52:35 +01:00
2020-12-19 13:31:38 +01:00
SerialPrint("I", F("FS"), "totalBytes=" + String(totalBytes));
SerialPrint("I", F("FS"), "usedBytes=" + String(usedBytes));
SerialPrint("I", F("FS"), "maxOpenFiles=" + String(maxOpenFiles));
SerialPrint("I", F("FS"), "maxPathLength=" + String(maxPathLength));
SerialPrint("I", F("FS"), "freeBytes=" + String(freeBytes));
SerialPrint("I", F("FS"), "freePer=" + String(freePer));
}
else {
SerialPrint("E", F("FS"), F("FS info error"));
}
2020-12-18 23:52:35 +01:00
}
bool getInfo(FSInfo& info) {
return FileFS.info(info);
}