5#include <Adafruit_LittleFS.h>
6#include <InternalFileSystem.h>
7using namespace Adafruit_LittleFS_Namespace;
8#define FS_INSTANCE InternalFS
9#define FS_BEGIN() InternalFS.begin()
10#define FS_OPEN_R(p) InternalFS.open(p, FILE_O_READ)
11#define FS_OPEN_W(p) InternalFS.open(p, FILE_O_WRITE)
14#define FS_INSTANCE LittleFS
15#define FS_BEGIN() LittleFS.begin(true)
16#define FS_OPEN_R(p) LittleFS.open(p, "r")
17#define FS_OPEN_W(p) LittleFS.open(p, "w")
30 bool exists(
const char* path)
override
32#ifndef HOST_TEST_BUILD
33 return FS_INSTANCE.exists(path);
36 FILE* file = fopen(path,
"r");
46 bool readFile(
const char* path, std::string& content)
override
48#ifndef HOST_TEST_BUILD
54 File file = FS_OPEN_R(path);
60 String arduinoContent = file.readString();
61 content = arduinoContent.c_str();
66 std::ifstream inFile(path);
73 std::string((std::istreambuf_iterator<char>(inFile)), std::istreambuf_iterator<char>());
78 bool writeFile(
const char* path,
const std::string& content)
override
80#ifndef HOST_TEST_BUILD
86 File file = FS_OPEN_W(path);
92 if (file.print(content.c_str()) == 0)
102 std::ofstream outFile(path);
109 return outFile.good();
Abstract interface for file system operations.
File system implementation using LittleFS for embedded targets.
bool exists(const char *path) override
Check if a file exists.
bool writeFile(const char *path, const std::string &content) override
Write content to a file.
bool readFile(const char *path, std::string &content) override
Read entire file content.
IFileSystem * createFileSystem()