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

Function cbm_expand_user_path

src/cli/cli.c:2409–2424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2407}
2408
2409static bool cbm_expand_user_path(const char *home_dir, const char *value, char *out,
2410 size_t out_sz) {
2411 if (!home_dir || !home_dir[0] || !value || !value[0] || !out || out_sz == 0U) {
2412 return false;
2413 }
2414 int written = -1;
2415 if (strcmp(value, "~") == 0) {
2416 written = snprintf(out, out_sz, "%s", home_dir);
2417 } else if (value[0] == '~' && (value[1] == '/' || value[1] == '\\')) {
2418 written = snprintf(out, out_sz, "%s/%s", home_dir, value + 2);
2419 } else if (value[0] == '/' || (isalpha((unsigned char)value[0]) && value[1] == ':' &&
2420 (value[2] == '/' || value[2] == '\\'))) {
2421 written = snprintf(out, out_sz, "%s", value);
2422 }
2423 return written >= 0 && (size_t)written < out_sz;
2424}
2425
2426static void cbm_env_home_dir(const char *env_name, const char *home_dir, const char *fallback,
2427 char *out, size_t out_sz) {

Callers 6

cbm_env_home_dirFunction · 0.85
cbm_openclaw_state_dirFunction · 0.85
cbm_openclaw_config_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected