Callers should not each re-derive these; a caller that resolved the home * directory differently would classify the same path differently. * * The value is the CANONICAL form of $HOME (then %USERPROFILE%), through the * same resolver callers apply to the path they classify. The policy compares * the two byte for byte, and a home reached through a link — "/home" kept on * another volume, a ma
| 631 | * does: no lock, a changed environment is seen at once, and the pointer stays |
| 632 | * valid until the next call on the same thread. */ |
| 633 | const char *cbm_workspace_home_dir(void) { |
| 634 | static CBM_TLS char resolved[CBM_SZ_4K]; |
| 635 | char raw[CBM_SZ_4K]; |
| 636 | const char *home = cbm_safe_getenv("HOME", raw, sizeof(raw), NULL); |
| 637 | if (!home || !home[0]) { |
| 638 | home = cbm_safe_getenv("USERPROFILE", raw, sizeof(raw), NULL); |
| 639 | } |
| 640 | if (!home || !home[0]) { |
| 641 | return NULL; |
| 642 | } |
| 643 | if (!cbm_canonical_path(home, resolved, sizeof(resolved))) { |
| 644 | memcpy(resolved, raw, strlen(raw) + 1); |
| 645 | } |
| 646 | cbm_normalize_path_sep(resolved); |
| 647 | return resolved; |
| 648 | } |
| 649 | |
| 650 | const char *cbm_workspace_cache_dir(void) { |
| 651 | return cbm_resolve_cache_dir(); |