Mbed OS Reference
|
FileSystemStore is a lightweight implementation of the KVStore interface over file systems. More...
#include <FileSystemStore.h>
Public Types | |
typedef struct mbed::KVStore::info | info_t |
Holds key information. More... | |
Public Member Functions | |
FileSystemStore (FileSystem *fs) | |
Create FileSystemStore - A Key Value API on top of FS. More... | |
virtual | ~FileSystemStore () |
Destroy FileSystemStore instance. More... | |
virtual int | init () |
Initialize FileSystemStore, checking validity of KVStore writing folder and if it doesn't exist, creating it. More... | |
virtual int | deinit () |
Deinitialize FileSystemStore, release and free resources. More... | |
virtual int | reset () |
Reset FileSystemStore contents (clear all keys) More... | |
virtual int | set (const char *key, const void *buffer, size_t size, uint32_t create_flags) |
Set one FileSystemStore item, given key and value. More... | |
virtual int | get (const char *key, void *buffer, size_t buffer_size, size_t *actual_size=NULL, size_t offset=0) |
Get one FileSystemStore item by given key. More... | |
virtual int | get_info (const char *key, info_t *info) |
Get information of a given key. More... | |
virtual int | remove (const char *key) |
Remove a FileSystemStore item by given key. More... | |
virtual int | set_start (set_handle_t *handle, const char *key, size_t final_data_size, uint32_t create_flags) |
Start an incremental FileSystemStore set sequence. More... | |
virtual int | set_add_data (set_handle_t handle, const void *value_data, size_t data_size) |
Add data to incremental FileSystemStore set sequence. More... | |
virtual int | set_finalize (set_handle_t handle) |
Finalize an incremental FileSystemStore set sequence. More... | |
virtual int | iterator_open (iterator_t *it, const char *prefix=NULL) |
Start an iteration over FileSystemStore keys. More... | |
virtual int | iterator_next (iterator_t it, char *key, size_t key_size) |
Get next key in iteration. More... | |
virtual int | iterator_close (iterator_t it) |
Close iteration. More... | |
bool | is_valid_key (const char *key) const |
Convenience function for checking key validity. More... | |
FileSystemStore is a lightweight implementation of the KVStore interface over file systems.
FileSystemStore implements the get/set interface using files, where a single file represents each key. A key is represented by the file name, and its value is stored as file data. Therefore, FileSystemStore imitates the get/set actions using simple file operations. Set is achieved using open-write-close, get using open-read-close and so on.
All files are concentrated under a single directory, whose name is hard coded. So actions such as "reset" are mapped to the deletion of all files under this directory, and iteration actions use file system APIs to traverse the directory.
Definition at line 42 of file FileSystemStore.h.
|
inherited |
Holds key information.
FileSystemStore | ( | FileSystem * | fs | ) |
Create FileSystemStore - A Key Value API on top of FS.
fs | File system (FAT/LITTLE) on top of which FileSystemStore is adding KV API |
|
virtual |
Destroy FileSystemStore instance.
Definition at line 54 of file FileSystemStore.h.
|
virtual |
Initialize FileSystemStore, checking validity of KVStore writing folder and if it doesn't exist, creating it.
Implements KVStore.
|
virtual |
Deinitialize FileSystemStore, release and free resources.
Implements KVStore.
|
virtual |
Reset FileSystemStore contents (clear all keys)
Implements KVStore.
|
virtual |
Set one FileSystemStore item, given key and value.
[in] | key | Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. |
[in] | buffer | Value data buffer. |
[in] | size | Value data size. |
[in] | create_flags | Flag mask. |
Implements KVStore.
|
virtual |
Get one FileSystemStore item by given key.
[in] | key | Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. |
[in] | buffer | Value data buffer. |
[in] | buffer_size | Value data buffer size. |
[out] | actual_size | Actual read size. |
[in] | offset | Offset to read from in data. |
Implements KVStore.
|
virtual |
Get information of a given key.
The returned info contains size and flags
[in] | key | Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. |
[out] | info | Returned information structure. |
Implements KVStore.
|
virtual |
Remove a FileSystemStore item by given key.
[in] | key | Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. |
Implements KVStore.
|
virtual |
Start an incremental FileSystemStore set sequence.
This operation is blocking other operations. Any get/set/remove/iterator operation will be blocked until set_finalize is called.
[out] | handle | Returned incremental set handle. |
[in] | key | Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. |
[in] | final_data_size | Final value data size. |
[in] | create_flags | Flag mask. |
Implements KVStore.
|
virtual |
Add data to incremental FileSystemStore set sequence.
This operation is blocking other operations. Any get/set/remove operation will be blocked until set_finalize is called.
[in] | handle | Incremental set handle. |
[in] | value_data | Value data to add. |
[in] | data_size | Value data size. |
Implements KVStore.
|
virtual |
Finalize an incremental FileSystemStore set sequence.
[in] | handle | Incremental set handle. |
Implements KVStore.
|
virtual |
Start an iteration over FileSystemStore keys.
There are no issues with any other operations while iterator is open.
[out] | it | Returned iterator handle. |
[in] | prefix | Key prefix (null for all keys). |
Implements KVStore.
|
virtual |
Get next key in iteration.
There are no issues with any other operations while iterator is open.
[in] | it | Iterator handle. |
[in] | key | Buffer for returned key. |
[in] | key_size | Key buffer size. |
Implements KVStore.
|
virtual |
Close iteration.
[in] | it | Iterator handle. |
Implements KVStore.
|
inherited |