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

Function cbm_expand_user_path

src/cli/cli.c:2222–2237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2220}
2221
2222static bool cbm_expand_user_path(const char *home_dir, const char *value, char *out,
2223 size_t out_sz) {
2224 if (!home_dir || !home_dir[0] || !value || !value[0] || !out || out_sz == 0U) {
2225 return false;
2226 }
2227 int written = -1;
2228 if (strcmp(value, "~") == 0) {
2229 written = snprintf(out, out_sz, "%s", home_dir);
2230 } else if (value[0] == '~' && (value[1] == '/' || value[1] == '\\')) {
2231 written = snprintf(out, out_sz, "%s/%s", home_dir, value + 2);
2232 } else if (value[0] == '/' || (isalpha((unsigned char)value[0]) && value[1] == ':' &&
2233 (value[2] == '/' || value[2] == '\\'))) {
2234 written = snprintf(out, out_sz, "%s", value);
2235 }
2236 return written >= 0 && (size_t)written < out_sz;
2237}
2238
2239static void cbm_env_home_dir(const char *env_name, const char *home_dir, const char *fallback,
2240 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