Count .db files in the cache directory. */
| 9089 | |
| 9090 | /* Count .db files in the cache directory. */ |
| 9091 | static int count_db_indexes(const char *home) { |
| 9092 | const char *cache_dir = get_cache_dir(home); |
| 9093 | if (!cache_dir) { |
| 9094 | return 0; |
| 9095 | } |
| 9096 | cbm_dir_t *d = cbm_opendir(cache_dir); |
| 9097 | if (!d) { |
| 9098 | return 0; |
| 9099 | } |
| 9100 | int count = 0; |
| 9101 | cbm_dirent_t *ent; |
| 9102 | while ((ent = cbm_readdir(d)) != NULL) { |
| 9103 | size_t len = strlen(ent->name); |
| 9104 | if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) { |
| 9105 | count++; |
| 9106 | } |
| 9107 | } |
| 9108 | cbm_closedir(d); |
| 9109 | return count; |
| 9110 | } |
| 9111 | |
| 9112 | /* Handle pre-existing indexes during (re)install (#607). |
| 9113 | * |
no test coverage detected