| 341 | } |
| 342 | |
| 343 | void |
| 344 | ghb_dvd_set_current(const gchar *name, signal_user_data_t *ud) |
| 345 | { |
| 346 | #if !defined(_WIN32) |
| 347 | GFile *gfile; |
| 348 | GFileInfo *info; |
| 349 | gchar *resolved = ghb_resolve_symlink(name); |
| 350 | |
| 351 | if (ud->current_dvd_device != NULL) |
| 352 | { |
| 353 | g_free(ud->current_dvd_device); |
| 354 | ud->current_dvd_device = NULL; |
| 355 | } |
| 356 | gfile = g_file_new_for_path(resolved); |
| 357 | info = g_file_query_info(gfile, |
| 358 | G_FILE_ATTRIBUTE_STANDARD_TYPE, |
| 359 | G_FILE_QUERY_INFO_NONE, NULL, NULL); |
| 360 | if (info != NULL) |
| 361 | { |
| 362 | if (g_file_info_get_file_type(info) == G_FILE_TYPE_SPECIAL) |
| 363 | { |
| 364 | // I could go through the trouble to scan the connected drives and |
| 365 | // verify that this device is connected and is a DVD. But I don't |
| 366 | // think its necessary. |
| 367 | ud->current_dvd_device = resolved; |
| 368 | } |
| 369 | else |
| 370 | { |
| 371 | g_free(resolved); |
| 372 | } |
| 373 | g_object_unref(info); |
| 374 | } |
| 375 | else |
| 376 | { |
| 377 | g_free(resolved); |
| 378 | } |
| 379 | g_object_unref(gfile); |
| 380 | #else |
| 381 | gchar drive[4]; |
| 382 | guint dtype; |
| 383 | |
| 384 | if (ud->current_dvd_device != NULL) |
| 385 | { |
| 386 | g_free(ud->current_dvd_device); |
| 387 | ud->current_dvd_device = NULL; |
| 388 | } |
| 389 | g_strlcpy(drive, name, 4); |
| 390 | dtype = GetDriveType(drive); |
| 391 | if (dtype == DRIVE_CDROM) |
| 392 | { |
| 393 | ud->current_dvd_device = g_strdup(name); |
| 394 | } |
| 395 | #endif |
| 396 | } |
no test coverage detected