| 64 | } |
| 65 | |
| 66 | static gboolean |
| 67 | validate_settings (signal_user_data_t *ud, GhbValue *settings, gint batch) |
| 68 | { |
| 69 | // Check to see if the dest file exists or is |
| 70 | // already in the queue |
| 71 | const gchar *dest; |
| 72 | gint count, ii; |
| 73 | gint title_id, titleindex; |
| 74 | const hb_title_t *title; |
| 75 | GtkWindow *hb_window; |
| 76 | gboolean dest_in_queue = FALSE; |
| 77 | gboolean dest_exists = FALSE; |
| 78 | |
| 79 | hb_window = GTK_WINDOW(ghb_builder_widget("hb_window")); |
| 80 | |
| 81 | title_id = ghb_dict_get_int(settings, "title"); |
| 82 | title = ghb_lookup_title(title_id, &titleindex); |
| 83 | if (title == NULL) return FALSE; |
| 84 | dest = ghb_dict_get_string(settings, "destination"); |
| 85 | count = ghb_array_len(ud->queue); |
| 86 | for (ii = 0; ii < count; ii++) |
| 87 | { |
| 88 | GhbValue *queueDict, *uiDict; |
| 89 | const gchar *filename; |
| 90 | |
| 91 | queueDict = ghb_array_get(ud->queue, ii); |
| 92 | uiDict = ghb_dict_get(queueDict, "uiSettings"); |
| 93 | filename = ghb_dict_get_string(uiDict, "destination"); |
| 94 | if (g_strcmp0(dest, filename) == 0) |
| 95 | { |
| 96 | dest_in_queue = TRUE; |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | gchar *destdir = g_path_get_dirname(dest); |
| 101 | if (!g_file_test(destdir, G_FILE_TEST_IS_DIR)) |
| 102 | { |
| 103 | ghb_alert_dialog_show(GTK_MESSAGE_ERROR, _("Invalid Destination"), |
| 104 | _("“%s” is is not a valid directory."), destdir); |
| 105 | g_free(destdir); |
| 106 | return FALSE; |
| 107 | } |
| 108 | #if !defined(_WIN32) |
| 109 | // This doesn't work properly on windows |
| 110 | if (g_access(destdir, R_OK|W_OK) != 0) |
| 111 | { |
| 112 | ghb_alert_dialog_show(GTK_MESSAGE_ERROR, _("Invalid Destination"), |
| 113 | _("“%s” is not a writable directory."), destdir); |
| 114 | g_free(destdir); |
| 115 | return FALSE; |
| 116 | } |
| 117 | #endif |
| 118 | g_free(destdir); |
| 119 | dest_exists = g_file_test(dest, G_FILE_TEST_EXISTS); |
| 120 | |
| 121 | if (dest_exists) |
| 122 | { |
| 123 | if (!ghb_question_dialog_run(hb_window, GHB_ACTION_DESTRUCTIVE, |
no test coverage detected