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

Function ensure_parent_dir

src/cli/cli.c:3178–3197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3176}
3177
3178static int ensure_parent_dir(const char *path) {
3179 if (!path || !path[0]) {
3180 return CLI_ERR;
3181 }
3182 char dir[CLI_BUF_1K];
3183 int written = snprintf(dir, sizeof(dir), "%s", path);
3184 if (written < 0 || (size_t)written >= sizeof(dir)) {
3185 return CLI_ERR;
3186 }
3187 char *last_slash = strrchr(dir, '/');
3188 char *last_backslash = strrchr(dir, '\\');
3189 if (last_backslash && (!last_slash || last_backslash > last_slash)) {
3190 last_slash = last_backslash;
3191 }
3192 if (!last_slash || last_slash == dir) {
3193 return CLI_OK;
3194 }
3195 *last_slash = '\0';
3196 return mkdirp(dir, DIR_PERMS) == 0 ? CLI_OK : CLI_ERR;
3197}
3198
3199int cbm_upsert_instructions(const char *path, const char *content) {
3200 if (!path || !content) {

Calls 1

mkdirpFunction · 0.85

Tested by

no test coverage detected