MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / config_sync_parent_directory

Function config_sync_parent_directory

src/ui/config.c:323–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323static bool config_sync_parent_directory(const char *path) {
324 char directory[CBM_SZ_1K];
325 if (!config_parent_directory(path, directory, sizeof(directory))) {
326 return false;
327 }
328 int flags = O_RDONLY;
329#ifdef O_DIRECTORY
330 flags |= O_DIRECTORY;
331#endif
332 int descriptor = open(directory, flags);
333 if (descriptor < 0) {
334 return false;
335 }
336 bool synced = config_sync_descriptor(descriptor);
337 int sync_error = synced ? 0 : errno;
338 (void)close(descriptor);
339#ifdef ENOTSUP
340 if (!synced && sync_error == ENOTSUP) {
341 synced = true;
342 }
343#endif
344#ifdef EOPNOTSUPP
345 if (!synced && sync_error == EOPNOTSUPP) {
346 synced = true;
347 }
348#endif
349 if (!synced && sync_error == EINVAL) {
350 /* Some POSIX filesystems do not implement directory fsync. The temp
351 * file itself was already synced and rename publication is atomic. */
352 synced = true;
353 }
354 return synced;
355}
356
357static bool config_write_atomic(const char *path, const char *json, size_t json_length) {
358 char temporary[CBM_SZ_2K];

Callers 1

config_write_atomicFunction · 0.85

Calls 4

config_parent_directoryFunction · 0.85
config_sync_descriptorFunction · 0.85
openFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected