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

Function ensure_parent_dir

src/cli/cli.c:3172–3191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Calls 1

mkdirpFunction · 0.85

Tested by

no test coverage detected