| 460 | /* ── App config directories (cross-platform) ────────── */ |
| 461 | |
| 462 | const char *cbm_app_config_dir(void) { |
| 463 | static CBM_TLS char buf[CBM_SZ_1K]; |
| 464 | char tmp[CBM_SZ_256] = ""; |
| 465 | #ifdef _WIN32 |
| 466 | cbm_safe_getenv("APPDATA", tmp, sizeof(tmp), NULL); |
| 467 | if (tmp[0]) { |
| 468 | snprintf(buf, sizeof(buf), "%s", tmp); |
| 469 | cbm_normalize_path_sep(buf); |
| 470 | return buf; |
| 471 | } |
| 472 | const char *home = cbm_get_home_dir(); |
| 473 | if (home) { |
| 474 | snprintf(buf, sizeof(buf), "%s/AppData/Roaming", home); |
| 475 | return buf; |
| 476 | } |
| 477 | return NULL; |
| 478 | #else |
| 479 | /* Linux: XDG_CONFIG_HOME or ~/.config */ |
| 480 | cbm_safe_getenv("XDG_CONFIG_HOME", tmp, sizeof(tmp), NULL); |
| 481 | if (tmp[0]) { |
| 482 | snprintf(buf, sizeof(buf), "%s", tmp); |
| 483 | return buf; |
| 484 | } |
| 485 | const char *home = cbm_get_home_dir(); |
| 486 | if (home) { |
| 487 | snprintf(buf, sizeof(buf), "%s/.config", home); |
| 488 | return buf; |
| 489 | } |
| 490 | return NULL; |
| 491 | #endif /* _WIN32 */ |
| 492 | } |
| 493 | |
| 494 | const char *cbm_app_local_dir(void) { |
| 495 | #ifdef _WIN32 |
no test coverage detected