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

Function hb_remove_previews

libhb/hb.c:316–359  ·  view source on GitHub ↗

* Deletes current previews associated with titles * @param h Handle to hb_handle_t */

Source from the content-addressed store, hash-verified

314 * @param h Handle to hb_handle_t
315 */
316void hb_remove_previews( hb_handle_t * h )
317{
318 char * filename;
319 const char * dirname;
320 hb_title_t * title;
321 int i, count, len;
322 DIR * dir;
323 struct dirent * entry;
324
325 dirname = hb_get_temporary_directory();
326 dir = opendir( dirname );
327 if (dir == NULL)
328 {
329 return;
330 }
331
332 count = hb_list_count( h->title_set.list_title );
333 while( ( entry = readdir( dir ) ) )
334 {
335 if( entry->d_name[0] == '.' )
336 {
337 continue;
338 }
339 for( i = 0; i < count; i++ )
340 {
341 title = hb_list_item( h->title_set.list_title, i );
342 filename = hb_strdup_printf("%d_%d", h->id, title->index);
343 len = snprintf( filename, 1024, "%d_%d", h->id, title->index );
344 if (strncmp(entry->d_name, filename, len) == 0)
345 {
346 free(filename);
347 filename = hb_strdup_printf("%s/%s", dirname, entry->d_name);
348 int ulerr = unlink( filename );
349 if (ulerr < 0) {
350 hb_log("Unable to remove preview: %i - %s", ulerr, filename);
351 }
352 free(filename);
353 break;
354 }
355 free(filename);
356 }
357 }
358 closedir( dir );
359}
360
361/**
362 * Initializes a scan of the by calling hb_scan_init

Callers 2

hb_scanFunction · 0.85
thread_funcFunction · 0.85

Calls 5

hb_list_countFunction · 0.85
hb_list_itemFunction · 0.85
hb_strdup_printfFunction · 0.85
hb_logFunction · 0.85

Tested by

no test coverage detected