Files
ETcontroller_PRO/include/fsmount.h
2025-07-27 15:49:40 +02:00

39 lines
1.0 KiB
C++

#pragma once
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
#include <DebugLog.h>
#include <Arduino.h>
#include <FFat.h>
#include <mutex>
class FSmount
{
public:
FSmount()
{
if (!FFat.begin(false))
{
LOG_ERROR("Unable to mount filesystem without formatting");
if (!FFat.begin(true))
{
LOG_ERROR("Formatted and mounted filesystem");
}
}
LOG_INFO("Local Filesystem Mounted Correctly");
const auto totalBytes = FFat.totalBytes();
const auto freeBytes = FFat.freeBytes();
const auto usedBytes = FFat.usedBytes();
const auto mountPoint = FFat.mountpoint();
LOG_INFO("Local filesystem, total", totalBytes / 1024, "KB - used", usedBytes / 1024, "KB - free", freeBytes / 1024, "KB");
LOG_INFO("Local filesystem, mountpoint", mountPoint);
}
~FSmount()
{
FFat.end(); // unmout filesystem to avoid corruption
LOG_INFO("Local Filesystem Unmounted Correctly");
}
};