include/sig/persistence/sig_persistence_file.h
extern const sig_persistence_module sig_persistence_file_module;
The file backend, registered as "file". Its config string (passed to sig_persistence_create) is the base directory; NULL or "" is SIG_ERR_INVALID_ARG. create does not check or create the directory. A key is stored at <base_dir>/<ns>/<key>.cfg for the namespaces "configurations" and "services", and at <base_dir>/<ns>/<key>.sig for any other namespace. A namespace must match [A-Za-z0-9_-]{1,64}. A key may be any string of 1 to 128 bytes that contains no '/', no ".." and no control character (below 0x20, or 0x7f), so "My Svc" or "v1.2" are keys. Anything else is SIG_ERR_INVALID_ARG, before the filesystem is touched. save creates every missing directory along <base_dir>/<ns> (mode 0755), the base directory included, and writes atomically: <key>.<ext>.tmp is written, fsync'ed and renamed over the final file, so a reader or a crash never sees a half-written file. On failure the old content is left in place. list reports the regular files named <key>.<ext> (a stem that is a valid key, the namespace's extension) directly inside the namespace directory, extension stripped, sorted (byte order). Temp files, other extensions, stems that are not valid keys and subdirectories are ignored. A missing namespace directory lists zero keys; any other failure to read it is SIG_ERR_PLATFORM.