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

Function ensure_parent_dir

src/cli/cli.c:3815–3834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3813}
3814
3815static int ensure_parent_dir(const char *path) {
3816 if (!path || !path[0]) {
3817 return CLI_ERR;
3818 }
3819 char dir[CLI_BUF_1K];
3820 int written = snprintf(dir, sizeof(dir), "%s", path);
3821 if (written < 0 || (size_t)written >= sizeof(dir)) {
3822 return CLI_ERR;
3823 }
3824 char *last_slash = strrchr(dir, '/');
3825 char *last_backslash = strrchr(dir, '\\');
3826 if (last_backslash && (!last_slash || last_backslash > last_slash)) {
3827 last_slash = last_backslash;
3828 }
3829 if (!last_slash || last_slash == dir) {
3830 return CLI_OK;
3831 }
3832 *last_slash = '\0';
3833 return mkdirp(dir, DIR_PERMS) == 0 ? CLI_OK : CLI_ERR;
3834}
3835
3836int cbm_upsert_instructions(const char *path, const char *content) {
3837 if (!path || !content) {

Calls 1

mkdirpFunction · 0.85

Tested by

no test coverage detected