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

Function cbm_openclaw_state_dir

src/cli/cli.c:2322–2348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2320}
2321
2322static bool cbm_openclaw_state_dir(const char *home_dir, char *out, size_t out_sz) {
2323 char internal_home[CLI_BUF_1K];
2324 if (!cbm_openclaw_internal_home(home_dir, internal_home, sizeof(internal_home))) {
2325 return false;
2326 }
2327 char env_buf[CLI_BUF_1K];
2328 const char *custom = cbm_safe_getenv("OPENCLAW_STATE_DIR", env_buf, sizeof(env_buf), NULL);
2329 if (custom && custom[0]) {
2330 return cbm_expand_user_path(internal_home, custom, out, out_sz);
2331 }
2332 char profile_buf[CLI_BUF_256];
2333 const char *profile =
2334 cbm_safe_getenv("OPENCLAW_PROFILE", profile_buf, sizeof(profile_buf), NULL);
2335 const char *separator = "";
2336 const char *profile_name = "";
2337 if (profile && profile[0] && strcmp(profile, "default") != 0) {
2338 for (const unsigned char *p = (const unsigned char *)profile; *p; p++) {
2339 if (!isalnum(*p) && *p != '-' && *p != '_') {
2340 return false;
2341 }
2342 }
2343 separator = "-";
2344 profile_name = profile;
2345 }
2346 int written = snprintf(out, out_sz, "%s/.openclaw%s%s", internal_home, separator, profile_name);
2347 return written > 0 && (size_t)written < out_sz;
2348}
2349
2350static bool cbm_openclaw_config_path(const char *home_dir, char *out, size_t out_sz) {
2351 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