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

Function cbm_openclaw_state_dir

src/cli/cli.c:2288–2314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2286}
2287
2288static bool cbm_openclaw_state_dir(const char *home_dir, char *out, size_t out_sz) {
2289 char internal_home[CLI_BUF_1K];
2290 if (!cbm_openclaw_internal_home(home_dir, internal_home, sizeof(internal_home))) {
2291 return false;
2292 }
2293 char env_buf[CLI_BUF_1K];
2294 const char *custom = cbm_safe_getenv("OPENCLAW_STATE_DIR", env_buf, sizeof(env_buf), NULL);
2295 if (custom && custom[0]) {
2296 return cbm_expand_user_path(internal_home, custom, out, out_sz);
2297 }
2298 char profile_buf[CLI_BUF_256];
2299 const char *profile =
2300 cbm_safe_getenv("OPENCLAW_PROFILE", profile_buf, sizeof(profile_buf), NULL);
2301 const char *separator = "";
2302 const char *profile_name = "";
2303 if (profile && profile[0] && strcmp(profile, "default") != 0) {
2304 for (const unsigned char *p = (const unsigned char *)profile; *p; p++) {
2305 if (!isalnum(*p) && *p != '-' && *p != '_') {
2306 return false;
2307 }
2308 }
2309 separator = "-";
2310 profile_name = profile;
2311 }
2312 int written = snprintf(out, out_sz, "%s/.openclaw%s%s", internal_home, separator, profile_name);
2313 return written > 0 && (size_t)written < out_sz;
2314}
2315
2316static bool cbm_openclaw_config_path(const char *home_dir, char *out, size_t out_sz) {
2317 char internal_home[CLI_BUF_1K];

Callers 2

cbm_openclaw_config_pathFunction · 0.85
cbm_detect_agentsFunction · 0.85

Calls 3

cbm_safe_getenvFunction · 0.85
cbm_expand_user_pathFunction · 0.85

Tested by

no test coverage detected