* Deletes current previews associated with titles * @param h Handle to hb_handle_t */
| 314 | * @param h Handle to hb_handle_t |
| 315 | */ |
| 316 | void 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 |
no test coverage detected