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

Function ensure_parent_dir

src/cli/cli.c:3373–3392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3371}
3372
3373static int ensure_parent_dir(const char *path) {
3374 if (!path || !path[0]) {
3375 return CLI_ERR;
3376 }
3377 char dir[CLI_BUF_1K];
3378 int written = snprintf(dir, sizeof(dir), "%s", path);
3379 if (written < 0 || (size_t)written >= sizeof(dir)) {
3380 return CLI_ERR;
3381 }
3382 char *last_slash = strrchr(dir, '/');
3383 char *last_backslash = strrchr(dir, '\\');
3384 if (last_backslash && (!last_slash || last_backslash > last_slash)) {
3385 last_slash = last_backslash;
3386 }
3387 if (!last_slash || last_slash == dir) {
3388 return CLI_OK;
3389 }
3390 *last_slash = '\0';
3391 return mkdirp(dir, DIR_PERMS) == 0 ? CLI_OK : CLI_ERR;
3392}
3393
3394int cbm_upsert_instructions(const char *path, const char *content) {
3395 if (!path || !content) {

Calls 1

mkdirpFunction · 0.85

Tested by

no test coverage detected