resolve_store_fallback_scan — see forward declaration above resolve_store. */
| 2466 | |
| 2467 | /* resolve_store_fallback_scan — see forward declaration above resolve_store. */ |
| 2468 | static cbm_store_t *resolve_store_fallback_scan(const char *project) { |
| 2469 | char dir_path[CBM_SZ_1K]; |
| 2470 | cache_dir(dir_path, sizeof(dir_path)); |
| 2471 | cbm_dir_t *d = cbm_opendir(dir_path); |
| 2472 | if (!d) { |
| 2473 | return NULL; |
| 2474 | } |
| 2475 | cbm_store_t *found = NULL; |
| 2476 | cbm_dirent_t *entry; |
| 2477 | while ((entry = cbm_readdir(d)) != NULL) { |
| 2478 | const char *n = entry->name; |
| 2479 | size_t len = strlen(n); |
| 2480 | if (!is_project_db_file(n, len)) { |
| 2481 | continue; |
| 2482 | } |
| 2483 | char full_path[CBM_SZ_2K]; |
| 2484 | snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, n); |
| 2485 | char iname[CBM_SZ_1K]; |
| 2486 | cbm_store_t *st = NULL; |
| 2487 | if (db_internal_project_name(full_path, iname, sizeof(iname), &st)) { |
| 2488 | if (strcmp(iname, project) == 0) { |
| 2489 | found = st; /* adopt — caller takes ownership */ |
| 2490 | break; |
| 2491 | } |
| 2492 | cbm_store_close(st); |
| 2493 | } |
| 2494 | } |
| 2495 | cbm_closedir(d); |
| 2496 | return found; |
| 2497 | } |
| 2498 | |
| 2499 | /* Open a .db file briefly, collect node/edge counts and root_path, |
| 2500 | * then append a JSON entry to arr. */ |
no test coverage detected