Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::NVSFileSystem Class Reference

#include <NVSFS.h>

Public Member Functions

 NVSFileSystem ()
 Default constructor.
 
bool begin (bool formatOnFail=false)
 Initialize the NVS file system.
 
void end ()
 Deinitialize the NVS file system.
 
NVSFile open (const String &path, const String &mode)
 Open a file for reading or writing.
 
bool remove (const String &path)
 Remove a file from NVS storage.
 

Constructor & Destructor Documentation

◆ NVSFileSystem()

uniot::NVSFileSystem::NVSFileSystem ( )
inline

Default constructor.

Creates an uninitialized NVS file system instance. Call begin() before performing any file operations.

Member Function Documentation

◆ begin()

bool uniot::NVSFileSystem::begin ( bool formatOnFail = false)
inline

Initialize the NVS file system.

Opens the NVS namespace used for file storage operations. This must be called before any file operations can be performed.

Parameters
formatOnFailCurrently unused (NVS doesn't require formatting)
Return values
trueNVS namespace opened successfully
falseFailed to open NVS namespace
Note
The method uses a fixed namespace "uniot_files" for all file operations. This ensures isolation from other NVS usage in the application.

◆ end()

void uniot::NVSFileSystem::end ( )
inline

Deinitialize the NVS file system.

Closes the NVS namespace and marks the file system as uninitialized. Any subsequent file operations will fail until begin() is called again.

◆ open()

NVSFile uniot::NVSFileSystem::open ( const String & path,
const String & mode )
inline

Open a file for reading or writing.

Creates an NVSFile object for the specified path and access mode. The path is automatically normalized to a valid NVS key.

Parameters
pathFile path (will be converted to NVS key)
modeAccess mode ("r" for read, "w" for write)
Returns
NVSFile object for the specified file
Warning
If the file system is not initialized, returns an invalid NVSFile object. Always check the returned object with operator bool().
Note
Currently only supports "r" and "w" modes. Append mode ("a") and other modes are not yet implemented.

◆ remove()

bool uniot::NVSFileSystem::remove ( const String & path)
inline

Remove a file from NVS storage.

Deletes the NVS key corresponding to the specified file path. The operation is immediate and cannot be undone.

Parameters
pathFile path to remove
Return values
trueFile was successfully removed
falseFailed to remove file (may not exist or NVS error)
Note
If the file doesn't exist, the operation may still return true depending on the underlying NVS implementation.

The documentation for this class was generated from the following file: