42 bool mount()
override;
54 bool exists(
const std::string &path)
override;
61 bool remove(
const std::string &path)
override;
70 bool rename(
const std::string &from,
const std::string &to)
override;
78 bool readFile(
const std::string &path, std::vector<uint8_t> &buffer)
override;
88 bool readFileString(
const std::string &path, uint32_t startPosition, uint32_t length, std::string &buffer);
96 bool writeFile(
const std::string &path,
const std::vector<uint8_t> &data)
override;
105 bool writeFile(
const std::string& path,
const unsigned char* data,
size_t size)
override;
114 bool streamFile(
const std::string &path, std::function<
void(
const uint8_t *,
size_t)> chunkCallback)
override;
122 bool listDirectory(
const std::string &path, std::vector<FileInfo> &out)
override;
144 size_t getFileSize(
const std::string &path)
override;
156 bool appendToFile(
const std::string &path,
const uint8_t *data,
size_t size)
override;
177 std::unique_ptr<StorageFileReader>
openReader(
const std::string& path)
override;
186 std::string
resolvePath(
const std::string &path)
const;
Abstract interface for file and directory storage backends.
Concrete implementation of StorageManager using FatFs.
bool rename(const std::string &from, const std::string &to) override
Rename a file or directory.
bool exists(const std::string &path) override
Check if the path exists.
bool formatStorage() override
Format the storage device.
bool unmount() override
Unmount the filesystem.
FatFsStorageManager()
Construct a new FatFsStorageManager object.
bool mount() override
Mount the filesystem at the specified mount point.
bool createDirectory(const std::string &path) override
Create a directory at the specified path.
bool writeFile(const std::string &path, const std::vector< uint8_t > &data) override
Write a memory buffer to a file.
bool mounted
Indicates if the filesystem is currently mounted.
bool readFileString(const std::string &path, uint32_t startPosition, uint32_t length, std::string &buffer)
Read a file string into a std::string.
bool streamFile(const std::string &path, std::function< void(const uint8_t *, size_t)> chunkCallback) override
Stream a file in chunks via callback.
std::string mountPoint
Default mount point.
size_t getFileSize(const std::string &path) override
Get the size of a file.
bool appendToFile(const std::string &path, const uint8_t *data, size_t size) override
Append data to a file.
bool removeDirectory(const std::string &path) override
Remove a directory at the specified path.
bool listDirectory(const std::string &path, std::vector< FileInfo > &out) override
List the contents of a directory.
std::string resolvePath(const std::string &path) const
Helper function to normalize full path based on mountPoint and relative path.
bool isMounted() const override
Check if the filesystem is currently mounted.
bool readFile(const std::string &path, std::vector< uint8_t > &buffer) override
Read a file into a memory buffer.
bool remove(const std::string &path) override
Remove a file or directory at the specified path.
std::unique_ptr< StorageFileReader > openReader(const std::string &path) override
open a file for streaming read access.
SemaphoreHandle_t mutex
Optional lock for thread safety.
Abstract base class for storage access and file operations.