Concrete implementation of StorageManager using FatFs. More...
#include <FatFsStorageManager.h>
Inheritance diagram for FatFsStorageManager:
Collaboration diagram for FatFsStorageManager:Public Member Functions | |
| FatFsStorageManager () | |
| Construct a new FatFsStorageManager object. | |
| bool | mount () override |
| Mount the filesystem at the specified mount point. | |
| bool | unmount () override |
| Unmount the filesystem. | |
| bool | exists (const std::string &path) override |
| Check if the path exists. | |
| bool | remove (const std::string &path) override |
| Remove a file or directory at the specified path. | |
| bool | rename (const std::string &from, const std::string &to) override |
| Rename a file or directory. | |
| bool | readFile (const std::string &path, std::vector< uint8_t > &buffer) override |
| Read a file into a memory buffer. | |
| bool | readFileString (const std::string &path, uint32_t startPosition, uint32_t length, std::string &buffer) |
| Read a file string into a std::string. | |
| bool | writeFile (const std::string &path, const std::vector< uint8_t > &data) override |
| Write a memory buffer to a file. | |
| bool | writeFile (const std::string &path, const unsigned char *data, size_t size) override |
| Write raw data to a file. | |
| bool | streamFile (const std::string &path, std::function< void(const uint8_t *, size_t)> chunkCallback) override |
| Stream a file in chunks via callback. | |
| bool | listDirectory (const std::string &path, std::vector< FileInfo > &out) override |
| List the contents of a directory. | |
| bool | createDirectory (const std::string &path) override |
| Create a directory at the specified path. | |
| bool | removeDirectory (const std::string &path) override |
| Remove a directory at the specified path. | |
| 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 | isMounted () const override |
| Check if the filesystem is currently mounted. | |
| bool | formatStorage () override |
| Format the storage device. | |
| std::unique_ptr< StorageFileReader > | openReader (const std::string &path) override |
| open a file for streaming read access. | |
Public Member Functions inherited from StorageManager | |
| virtual | ~StorageManager ()=default |
Private Member Functions | |
| std::string | resolvePath (const std::string &path) const |
| Helper function to normalize full path based on mountPoint and relative path. | |
| bool | ensureMounted () |
| bool | probeMountPoint () |
| void | refreshMountState () |
Private Attributes | |
| bool | mounted = false |
| Indicates if the filesystem is currently mounted. | |
| std::string | mountPoint = "sd0" |
| Default mount point. | |
| SemaphoreHandle_t | mutex |
| Optional lock for thread safety. | |
Definition at line 30 of file FatFsStorageManager.h.
| FatFsStorageManager::FatFsStorageManager | ( | ) |
Construct a new FatFsStorageManager object.
Definition at line 27 of file FatFsStorageManager.cpp.
|
overridevirtual |
Append data to a file.
| path | Path to the file. |
| data | Pointer to the data buffer. |
| size | Size of the data buffer. |
| path | Path to the file. |
| data | Pointer to the data buffer. |
| size | Size of the data buffer. |
Implements StorageManager.
Definition at line 269 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
| path | Path to create the directory. |
Implements StorageManager.
Definition at line 120 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
private |
Definition at line 319 of file FatFsStorageManager.cpp.
References mount(), and mounted.
Referenced by appendToFile(), createDirectory(), exists(), getFileSize(), listDirectory(), openReader(), readFile(), readFileString(), remove(), removeDirectory(), rename(), streamFile(), writeFile(), and writeFile().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Check if the path exists.
Implements StorageManager.
Definition at line 65 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
Implements StorageManager.
Definition at line 350 of file FatFsStorageManager.cpp.
References mount(), mounted, mountPoint, and unmount().
Here is the call graph for this function:
|
overridevirtual |
Get the size of a file.
| path | Path to the file. |
| path | Path to the file. |
Implements StorageManager.
Definition at line 250 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
Implements StorageManager.
Definition at line 328 of file FatFsStorageManager.cpp.
References mounted.
|
overridevirtual |
List the contents of a directory.
| path | Path to the directory. |
| out | Output vector to fill with FileInfo objects. |
| path | Path to the directory. |
| out | Output vector to fill with FileInfo objects. |
Implements StorageManager.
Definition at line 89 of file FatFsStorageManager.cpp.
References ensureMounted(), FileInfo::isDirectory, FileInfo::isReadOnly, FileInfo::name, resolvePath(), FileInfo::size, and TRACE.
Here is the call graph for this function:
|
overridevirtual |
Mount the filesystem at the specified mount point.
Implements StorageManager.
Definition at line 30 of file FatFsStorageManager.cpp.
References mount(), mounted, mountPoint, probeMountPoint(), and TRACE.
Referenced by ensureMounted(), formatStorage(), and mount().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
| path | The file path |
Implements StorageManager.
Definition at line 414 of file FatFsStorageManager.cpp.
References ensureMounted(), and resolvePath().
Here is the call graph for this function:
|
private |
Definition at line 342 of file FatFsStorageManager.cpp.
References mountPoint.
Referenced by mount(), and refreshMountState().
Here is the caller graph for this function:
|
overridevirtual |
Read a file into a memory buffer.
| path | Path to the file. |
| buffer | Output buffer to fill with data. |
| path | Path to the file. |
| buffer | Output buffer to fill with data. |
Implements StorageManager.
Definition at line 142 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
virtual |
| path | Path to the file. |
| startPosition | Start position in the file. |
| length | Length of data to read. |
| buffer | Output string to fill with data. |
Implements StorageManager.
Definition at line 371 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
private |
Definition at line 333 of file FatFsStorageManager.cpp.
References mounted, probeMountPoint(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
Remove a file or directory at the specified path.
Implements StorageManager.
Definition at line 205 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
| path | Path to the directory to remove. |
Implements StorageManager.
Definition at line 131 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
Rename a file or directory.
| from | Current path of the file or directory. |
| to | New path for the file or directory. |
| from | Current path of the file or directory. |
| to | New path for the file or directory. |
Implements StorageManager.
Definition at line 216 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
private |
Definition at line 286 of file FatFsStorageManager.cpp.
References mountPoint.
Referenced by appendToFile(), createDirectory(), exists(), getFileSize(), listDirectory(), openReader(), readFile(), readFileString(), remove(), removeDirectory(), rename(), streamFile(), writeFile(), and writeFile().
Here is the caller graph for this function:
|
overridevirtual |
Stream a file in chunks via callback.
| path | Path to the file. |
| chunkCallback | Callback function to handle each chunk of data. |
| path | Path to the file. |
| chunkCallback | Callback function to handle each chunk of data. |
Implements StorageManager.
Definition at line 227 of file FatFsStorageManager.cpp.
References ensureMounted(), HTTP_BUFFER_SIZE, resolvePath(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
Unmount the filesystem.
Implements StorageManager.
Definition at line 57 of file FatFsStorageManager.cpp.
References mounted, mountPoint, and unmount().
Referenced by formatStorage(), and unmount().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Write a memory buffer to a file.
| path | Path to the file. |
| data | Data to write. |
| path | Path to the file. |
| data | Data to write. |
Implements StorageManager.
Definition at line 170 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
overridevirtual |
| path | Path to the file. |
| data | Pointer to the data buffer. |
| size | Size of the data buffer. |
Implements StorageManager.
Definition at line 186 of file FatFsStorageManager.cpp.
References ensureMounted(), resolvePath(), and TRACE.
Here is the call graph for this function:
|
private |
Definition at line 181 of file FatFsStorageManager.h.
Referenced by ensureMounted(), formatStorage(), isMounted(), mount(), refreshMountState(), and unmount().
|
private |
Definition at line 182 of file FatFsStorageManager.h.
Referenced by formatStorage(), mount(), probeMountPoint(), resolvePath(), and unmount().
|
private |
Definition at line 184 of file FatFsStorageManager.h.