CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
File Operations

Functions

SSDNode * setsOpen (VFS *vfs, strref path, int64 flush_interval)
 
bool setsClose (SSDNode **psets)
 
bool setsFlush (SSDNode *sets)
 
void setsSetDirty (SSDNode *sets)
 

Detailed Description

Functions for opening, closing, and persisting settings files.

Function Documentation

◆ setsClose()

bool setsClose ( SSDNode **  psets)

Closes a settings tree and ensures all changes are flushed to disk.

Performs a final flush of all pending changes, including checking all bound variables, then removes the tree from background monitoring and releases the tree object.

Parameters
psetsPointer to the settings tree root (will be set to NULL after closing)
Returns
true if successfully closed and flushed

◆ setsFlush()

bool setsFlush ( SSDNode *  sets)

Immediately flushes all changes to disk.

Normally changes are flushed automatically at the configured interval. This function forces an immediate flush of any pending changes, including checking all bound variables for modifications.

Parameters
setsThe settings tree root
Returns
true if flush was successful

◆ setsOpen()

SSDNode * setsOpen ( VFS vfs,
strref  path,
int64  flush_interval 
)

Opens a settings tree backed by a JSON file in a VFS.

Creates or loads a settings tree from the specified file. If the file doesn't exist or cannot be parsed, an empty settings tree is created. A background thread is automatically started to monitor the tree and flush changes periodically.

Parameters
vfsThe VFS instance to use for file access
pathPath to the JSON settings file within the VFS
flush_intervalTime interval between automatic flushes (in time units, e.g., timeS(30) for 30 seconds)
Returns
A new SSDNode representing the settings tree root (must be released with setsClose or objRelease)

Example:

VFS *vfs = vfsCreate();
SSDNode *settings = setsOpen(vfs, _S"config/app.json", timeS(60));
// ... use settings ...
setsClose(&settings);
#define vfsCreate(flags)
Definition vfsobj.h:77
bool setsClose(SSDNode **psets)
SSDNode * setsOpen(VFS *vfs, strref path, int64 flush_interval)
#define _S
Creates a static ASCII string from a string literal.
Definition strbase.h:392
#define timeS(s)
Definition time.h:18
VFS Object.
Definition vfsobj.h:25

◆ setsSetDirty()

void setsSetDirty ( SSDNode *  sets)

Marks the settings tree as dirty to force a save at the next flush interval.

This bypasses the normal change detection and ensures the tree will be written to disk at the next flush, even if no modifications were detected. Useful when making external changes that might not be caught by the normal change tracking.

Parameters
setsThe settings tree root