* hb_batch_init *********************************************************************** * **********************************************************************/
| 28 | * |
| 29 | **********************************************************************/ |
| 30 | hb_batch_t * hb_batch_init( hb_handle_t *h, char * path, hb_list_t * exclude_extensions ) |
| 31 | { |
| 32 | hb_batch_t * d; |
| 33 | hb_stat_t sb; |
| 34 | HB_DIR * dir; |
| 35 | struct dirent * entry; |
| 36 | char * filename; |
| 37 | int count, ii; |
| 38 | char ** files; |
| 39 | |
| 40 | if ( hb_stat( path, &sb ) ) |
| 41 | return NULL; |
| 42 | |
| 43 | if ( !S_ISDIR( sb.st_mode ) ) |
| 44 | return NULL; |
| 45 | |
| 46 | dir = hb_opendir(path); |
| 47 | if ( dir == NULL ) |
| 48 | return NULL; |
| 49 | |
| 50 | // Count the total number of entries |
| 51 | count = 0; |
| 52 | while (hb_readdir(dir)) |
| 53 | { |
| 54 | count++; |
| 55 | } |
| 56 | |
| 57 | if (count == 0) |
| 58 | { |
| 59 | return NULL; |
| 60 | } |
| 61 | |
| 62 | files = malloc(count * sizeof(char*)); |
| 63 | if (files == NULL) |
| 64 | { |
| 65 | return NULL; |
| 66 | } |
| 67 | |
| 68 | // Excluded Extensions |
| 69 | int extension_count = hb_list_count(exclude_extensions); |
| 70 | hb_log("Excluding %i file extension(s) from scan. ", extension_count); |
| 71 | |
| 72 | for (int i = 0; i < extension_count; i++ ) |
| 73 | { |
| 74 | char * file_extension = hb_list_item( exclude_extensions, i ); |
| 75 | hb_log(" - Excluding Extension: %s", file_extension); |
| 76 | } |
| 77 | |
| 78 | // Find all regular files |
| 79 | ii = 0; |
| 80 | hb_rewinddir(dir); |
| 81 | while ( (entry = hb_readdir( dir ) ) ) |
| 82 | { |
| 83 | filename = hb_strdup_printf( "%s" DIR_SEP_STR "%s", path, entry->d_name ); |
| 84 | |
| 85 | int excluded = 0; |
| 86 | for (int i = 0; i < extension_count; i++ ) |
| 87 | { |
no test coverage detected