resolve_store_fallback_scan — see forward declaration above resolve_store. */
| 2670 | |
| 2671 | /* resolve_store_fallback_scan — see forward declaration above resolve_store. */ |
| 2672 | static cbm_store_t *resolve_store_fallback_scan(const char *project) { |
| 2673 | char dir_path[CBM_SZ_1K]; |
| 2674 | cache_dir(dir_path, sizeof(dir_path)); |
| 2675 | cbm_dir_t *d = cbm_opendir(dir_path); |
| 2676 | if (!d) { |
| 2677 | return NULL; |
| 2678 | } |
| 2679 | cbm_store_t *found = NULL; |
| 2680 | cbm_dirent_t *entry; |
| 2681 | while ((entry = cbm_readdir(d)) != NULL) { |
| 2682 | const char *n = entry->name; |
| 2683 | size_t len = strlen(n); |
| 2684 | if (!is_project_db_file(n, len)) { |
| 2685 | continue; |
| 2686 | } |
| 2687 | char full_path[CBM_SZ_2K]; |
| 2688 | snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, n); |
| 2689 | char iname[CBM_SZ_1K]; |
| 2690 | cbm_store_t *st = NULL; |
| 2691 | if (db_internal_project_name(full_path, iname, sizeof(iname), &st)) { |
| 2692 | if (strcmp(iname, project) == 0) { |
| 2693 | found = st; /* adopt — caller takes ownership */ |
| 2694 | break; |
| 2695 | } |
| 2696 | cbm_store_close(st); |
| 2697 | } |
| 2698 | } |
| 2699 | cbm_closedir(d); |
| 2700 | return found; |
| 2701 | } |
| 2702 | |
| 2703 | typedef struct { |
| 2704 | char *name; |
no test coverage detected