103 #include <sys/stat.h>
104 #include <sys/types.h>
108 #include <amxc/amxc_macros.h>
131 when_null(parser, exit);
134 amxc_string_init(&dir, 0);
135 const char* storage_dir = GETP_CHAR(&parser->config,
"storage-path");
137 amxc_string_clean(&dir);
140 amxc_string_setf(&dir,
"%s", storage_dir);
141 amxc_string_resolve(&dir, &parser->config);
142 result = amxc_string_take_buffer(&dir);
169 "Failed to allocate mem for s_storage_dir");
221 if(access(file, F_OK) == 0) {
226 FILE* f = fopen(file,
"w");
228 SAH_TRACEZ_ERROR(
ME,
"Failed to create '%s': %s", file, strerror(errno));
235 const char*
const object) {
238 amxc_string_appendf(file_path,
"%s",
object);
239 amxc_string_append(file_path,
"_enabled.txt", 12);
250 when_null_trace(
s_storage_dir, exit, DEBUG,
"No persistency");
251 when_null(
object, exit);
253 amxc_string_t file_path;
254 amxc_string_init(&file_path, 0);
257 const char*
const file_path_cstr = amxc_string_get(&file_path, 0);
264 unlink(file_path_cstr);
267 amxc_string_clean(&file_path);
283 when_null_trace(
s_storage_dir, exit, DEBUG,
"No persistency");
284 when_null(
object, exit);
286 amxc_string_t file_path;
287 amxc_string_init(&file_path, 0);
290 const char*
const file_path_cstr = amxc_string_get(&file_path, 0);
292 rv = (access(file_path_cstr, F_OK) == 0) ?
true :
false;
294 amxc_string_clean(&file_path);
amxo_parser_t *PRIVATE xpon_mngr_get_parser(void)
static void create_enabled_file_path(amxc_string_t *const file_path, const char *const object)
bool persistency_is_enabled(const char *const object)
static char * s_storage_dir
static char * get_storage_dir(void)
void persistency_init(void)
void persistency_enable(const char *const object, bool enable)
void persistency_cleanup(void)
static const char *const STORAGE_DIR
const char * persistency_get_folder(void)
static void touch_file(const char *const file)
#define SAH_TRACEZ_DEBUG(zone, format,...)
#define SAH_TRACEZ_DEBUG2(zone, format,...)