Functions
mk_config_get_boolfunction
bool mk_config_get_bool(const char *key, bool def)
Get bool from the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
def | bool | Value for def. |
Returns True when the operation succeeds.
mk_config_get_floatfunction
float mk_config_get_float(const char *key, float def)
Get float from the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
def | float | Value for def. |
Returns The resulting value.
mk_config_get_intfunction
int mk_config_get_int(const char *key, int def)
Get int from the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
def | int | Value for def. |
Returns The resulting value.
mk_config_get_strfunction
const char * mk_config_get_str(const char *key, const char *def)
Get str from the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
def | const char * | Value for def. |
Returns A borrowed pointer, or NULL when unavailable.
mk_config_loadfunction
bool mk_config_load(const char *name)
Load (or start) a config backed by name in the storage directory.
A missing file starts an empty config; mk_config_save() will create it. The name is remembered for mk_config_save().
| Parameter | Type | Description |
|---|
name | const char * | Stable name. |
Returns True when the operation succeeds.
mk_config_savefunction
bool mk_config_save(void)
Persist the in-memory config to the file from the last mk_config_load().
Returns True when the operation succeeds.
mk_config_set_boolfunction
void mk_config_set_bool(const char *key, bool value)
Set bool on the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
value | bool | Value to use. |
mk_config_set_floatfunction
void mk_config_set_float(const char *key, float value)
Set float on the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
value | float | Value to use. |
mk_config_set_intfunction
void mk_config_set_int(const char *key, int value)
Set int on the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
value | int | Value to use. |
mk_config_set_strfunction
void mk_config_set_str(const char *key, const char *value)
Set str on the config.
| Parameter | Type | Description |
|---|
key | const char * | Value for key. |
value | const char * | Value to use. |
mk_storage_deletefunction
bool mk_storage_delete(const char *name)
Delete a named blob.
| Parameter | Type | Description |
|---|
name | const char * | Stable name. |
Returns True when the operation succeeds.
mk_storage_dirfunction
const char * mk_storage_dir(void)
Absolute writable directory (with trailing separator), or NULL if uninit.
Returns A borrowed pointer, or NULL when unavailable.
mk_storage_existsfunction
bool mk_storage_exists(const char *name)
True if a named blob exists in the storage directory.
| Parameter | Type | Description |
|---|
name | const char * | Stable name. |
Returns True when the operation succeeds.
mk_storage_flushfunction
bool mk_storage_flush(mk_storage_flush_fn callback, void *user_data)
Persist pending writes, then invoke callback (may be NULL).
Native platforms complete before returning and call back synchronously. Web syncs the IDBFS mount to IndexedDB and calls back on a later browser task, so treat the callback as asynchronous everywhere. Returns false if storage is uninitialized or another flush is still in flight.
| Parameter | Type | Description |
|---|
callback | mk_storage_flush_fn | Completion callback. |
user_data | void * | Caller-provided context. |
Returns True when the operation succeeds.
mk_storage_initfunction
bool mk_storage_init(const char *org, const char *app)
Resolve (and create) the per-user writable directory for org/app and make it the target for subsequent storage and config calls.
| Parameter | Type | Description |
|---|
org | const char * | Value for org. |
app | const char * | Value for app. |
Returns true on success.
mk_storage_is_durablefunction
bool mk_storage_is_durable(void)
True when a completed write is already durable without calling mk_storage_flush().
Native platforms write straight to the filesystem and return true. On web the storage directory is an IDBFS mount whose contents only reach IndexedDB when they are synced, so this returns false and writes survive a reload only after a successful flush.
Returns True when the condition holds.
mk_storage_readfunction
void * mk_storage_read(const char *name, size_t *out_size)
Read a named blob.
Returns a malloc'd buffer the caller must free(); writes the byte count to out_size (may be NULL). Returns NULL if missing.
| Parameter | Type | Description |
|---|
name | const char * | Stable name. |
out_size | size_t * | Receives the size. |
Returns A borrowed pointer, or NULL when unavailable.
mk_storage_writefunction
bool mk_storage_write(const char *name, const void *data, size_t size)
Write a named blob into the storage directory (overwrites).
name must be a plain filename (no path separators).
| Parameter | Type | Description |
|---|
name | const char * | Stable name. |
data | const void * | Data buffer. |
size | size_t | Size in bytes. |
Returns True when the operation succeeds.