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

Function ensure_parent_dir

src/cli/cli.c:3242–3261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3240}
3241
3242static int ensure_parent_dir(const char *path) {
3243 if (!path || !path[0]) {
3244 return CLI_ERR;
3245 }
3246 char dir[CLI_BUF_1K];
3247 int written = snprintf(dir, sizeof(dir), "%s", path);
3248 if (written < 0 || (size_t)written >= sizeof(dir)) {
3249 return CLI_ERR;
3250 }
3251 char *last_slash = strrchr(dir, '/');
3252 char *last_backslash = strrchr(dir, '\\');
3253 if (last_backslash && (!last_slash || last_backslash > last_slash)) {
3254 last_slash = last_backslash;
3255 }
3256 if (!last_slash || last_slash == dir) {
3257 return CLI_OK;
3258 }
3259 *last_slash = '\0';
3260 return mkdirp(dir, DIR_PERMS) == 0 ? CLI_OK : CLI_ERR;
3261}
3262
3263int cbm_upsert_instructions(const char *path, const char *content) {
3264 if (!path || !content) {

Calls 1

mkdirpFunction · 0.85

Tested by

no test coverage detected