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

Function cbm_expand_user_path

src/cli/cli.c:2278–2293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2276}
2277
2278static bool cbm_expand_user_path(const char *home_dir, const char *value, char *out,
2279 size_t out_sz) {
2280 if (!home_dir || !home_dir[0] || !value || !value[0] || !out || out_sz == 0U) {
2281 return false;
2282 }
2283 int written = -1;
2284 if (strcmp(value, "~") == 0) {
2285 written = snprintf(out, out_sz, "%s", home_dir);
2286 } else if (value[0] == '~' && (value[1] == '/' || value[1] == '\\')) {
2287 written = snprintf(out, out_sz, "%s/%s", home_dir, value + 2);
2288 } else if (value[0] == '/' || (isalpha((unsigned char)value[0]) && value[1] == ':' &&
2289 (value[2] == '/' || value[2] == '\\'))) {
2290 written = snprintf(out, out_sz, "%s", value);
2291 }
2292 return written >= 0 && (size_t)written < out_sz;
2293}
2294
2295static void cbm_env_home_dir(const char *env_name, const char *home_dir, const char *fallback,
2296 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