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

Function write_file_str

src/cli/cli.c:1315–1333  ·  view source on GitHub ↗

Write string to file, creating parent dirs if needed. */

Source from the content-addressed store, hash-verified

1313
1314/* Write string to file, creating parent dirs if needed. */
1315static int write_file_str(const char *path, const char *content) {
1316 /* Ensure parent directory */
1317 char dir[CLI_BUF_1K];
1318 snprintf(dir, sizeof(dir), "%s", path);
1319 char *last_slash = strrchr(dir, '/');
1320 if (last_slash) {
1321 *last_slash = '\0';
1322 mkdirp(dir, DIR_PERMS);
1323 }
1324
1325 FILE *f = fopen(path, "w");
1326 if (!f) {
1327 return CLI_ERR;
1328 }
1329 size_t len = strlen(content);
1330 size_t written = fwrite(content, CLI_ELEM_SIZE, len, f);
1331 (void)fclose(f);
1332 return written == len ? 0 : CLI_ERR;
1333}
1334
1335int cbm_upsert_instructions(const char *path, const char *content) {
1336 if (!path || !content) {

Callers 6

cbm_upsert_instructionsFunction · 0.85
cbm_remove_instructionsFunction · 0.85
cbm_upsert_codex_mcpFunction · 0.85
cbm_remove_codex_mcpFunction · 0.85
cbm_upsert_codex_hooksFunction · 0.85
cbm_remove_codex_hooksFunction · 0.85

Calls 1

mkdirpFunction · 0.85

Tested by

no test coverage detected