#include <Storage.h>
|
| | Storage (const String &path) |
| | Constructs a Storage object for a specific file.
|
| |
| virtual | ~Storage () |
| | Destructor.
|
| |
| virtual bool | store () |
| | Writes the current data to the file system.
|
| |
| virtual bool | restore () |
| | Loads data from the file system into memory.
|
| |
| virtual bool | clean () |
| | Clears data and removes the file from the file system.
|
| |
|
| static void | unmount () |
| | Explicitly unmounts the filesystem.
|
| |
|
| void | setPath (const String &path) |
| | Sets the file path, ensuring it starts with "/".
|
| |
|
| Bytes | mData |
| | The byte array containing the data to be stored or the loaded data.
|
| |
| String | mPath |
| | The file path where data is stored.
|
| |
◆ Storage()
| uniot::Storage::Storage |
( |
const String & | path | ) |
|
|
inline |
Constructs a Storage object for a specific file.
Creates a Storage instance associated with a specific file path. The constructor automatically mounts the filesystem if this is the first Storage instance created. File path will be prepended with "/" if not already present.
- Parameters
-
| path | The file path to use for storage (limited to 31 characters) |
◆ ~Storage()
| virtual uniot::Storage::~Storage |
( |
| ) |
|
|
inlinevirtual |
Destructor.
Decrements the instance counter and unmounts the filesystem when the last instance is destroyed
◆ clean()
| virtual bool uniot::Storage::clean |
( |
| ) |
|
|
inlinevirtual |
Clears data and removes the file from the file system.
Cleans up by both clearing the in-memory data and removing the associated file from the filesystem.
- Return values
-
| true | File was successfully removed |
| false | Failed to remove the file |
Reimplemented in uniot::CBORStorage, uniot::CrashStorage, and uniot::WifiStorage.
◆ restore()
| virtual bool uniot::Storage::restore |
( |
| ) |
|
|
inlinevirtual |
◆ setPath()
| void uniot::Storage::setPath |
( |
const String & | path | ) |
|
|
inlineprotected |
Sets the file path, ensuring it starts with "/".
- Parameters
-
| path | The file path to set (limited to 31 characters total) |
◆ store()
| virtual bool uniot::Storage::store |
( |
| ) |
|
|
inlinevirtual |
◆ unmount()
| static void uniot::Storage::unmount |
( |
| ) |
|
|
inlinestatic |
Explicitly unmounts the filesystem.
This method forcibly unmounts the filesystem regardless of how many Storage instances exist. Use with extreme caution as it will affect all other Storage instances.
- Warning
- This can cause other Storage instances to fail as they may attempt to access an unmounted filesystem
◆ mData
| Bytes uniot::Storage::mData |
|
protected |
The byte array containing the data to be stored or the loaded data.
This member stores the actual data that will be written to the file system or that has been read from the file system.
◆ mPath
| String uniot::Storage::mPath |
|
protected |
The file path where data is stored.
This is the full path to the file in the filesystem.
The documentation for this class was generated from the following files: