MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_batch_init

Function hb_batch_init

libhb/batch.c:30–147  ·  view source on GitHub ↗

* hb_batch_init *********************************************************************** * **********************************************************************/

Source from the content-addressed store, hash-verified

28 *
29 **********************************************************************/
30hb_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 {

Callers 1

ScanFuncFunction · 0.85

Calls 14

hb_statFunction · 0.85
hb_opendirFunction · 0.85
hb_readdirFunction · 0.85
hb_list_countFunction · 0.85
hb_logFunction · 0.85
hb_list_itemFunction · 0.85
hb_rewinddirFunction · 0.85
hb_strdup_printfFunction · 0.85
hb_str_ends_withFunction · 0.85
hb_deep_logFunction · 0.85
hb_list_initFunction · 0.85
hb_list_addFunction · 0.85

Tested by

no test coverage detected