web::uri build_connect(const web::uri& base_url, transport_type transport, const utility::string_t& query_string) { auto builder = build_uri(base_url, _XPLATSTR(""), query_string); return convert_to_websocket_url(builder, transport).to_uri(); //auto builder = build_uri(base_url, _XPLATSTR("connect"), transport, connection_data, query_string); //return convert_to_websocket_url(builder, transport).to_uri(); }
void test_new_from_file (void) { GError *error = NULL; const gchar *uri; uri = build_uri ("multi-pages.pdf"); document = poppler_document_new_from_file (uri, NULL, &error); gcut_assert_error (error); cut_assert_equal_int (3, poppler_document_get_n_pages (document)); }
static PopplerDocument * load_document (const gchar *fixture_data_component) { PopplerDocument *document; GError *error = NULL; const gchar *uri; uri = build_uri (fixture_data_component); document = poppler_document_new_from_file (uri, NULL, &error); gcut_assert_error (error); return document; }
static gboolean try_check_file (GIOSchedulerJob *io_job, GCancellable *cancellable, gpointer data) { AsyncExistenceJob *job = data; GFile *file; GFileInfo *info; GError *error; char *uri; retry: error = NULL; uri = build_uri (job); file = g_file_new_for_uri (uri); info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, cancellable, &error); if (info != NULL) { /* file already exists, iterate again */ g_object_unref (info); g_object_unref (file); g_free (uri); (job->iteration)++; goto retry; } else { /* see the error to check whether the location is not accessible * or the file does not exist. */ if (error->code == G_IO_ERROR_NOT_FOUND) { GFile *parent; /* if the parent directory doesn't exist as well, forget the saved * directory and treat this as a generic error. */ parent = g_file_get_parent (file); if (!g_file_query_exists (parent, NULL)) { (job->type)++; job->iteration = 0; g_object_unref (file); g_object_unref (parent); goto retry; } else { job->retval = uri; g_object_unref (parent); goto out; } } else { /* another kind of error, assume this location is not * accessible. */ g_free (uri); if (job->type == TEST_TMP) { job->retval = NULL; goto out; } else { (job->type)++; job->iteration = 0; g_error_free (error); g_object_unref (file); goto retry; } } } out: g_error_free (error); g_object_unref (file); g_io_scheduler_job_send_to_mainloop_async (io_job, check_file_done, job, NULL); return FALSE; }
web::uri build_abort(const web::uri &base_url, transport_type transport, const utility::string_t& connection_data, const utility::string_t &query_string) { return build_uri(base_url, _XPLATSTR("abort"), transport, connection_data, query_string).to_uri(); }
web::uri build_start(const web::uri &base_url, const utility::string_t &query_string) { return build_uri(base_url, _XPLATSTR(""), query_string).to_uri(); }
web::uri build_reconnect(const web::uri& base_url, transport_type transport, const utility::string_t& last_message_id, const utility::string_t& groups_token, const utility::string_t& query_string) { auto builder = build_uri(base_url, _XPLATSTR("reconnect"), transport, query_string, last_message_id, groups_token); return convert_to_websocket_url(builder, transport).to_uri(); }
static int file_sel_response_cb (GtkWidget *widget, int response, DialogData *data) { GtkFileChooser *file_sel = GTK_FILE_CHOOSER (widget); FrWindow *window = data->window; char *selected_folder; gboolean update, UNUSED_VARIABLE recursive, follow_links; const char *include_files; const char *exclude_files; const char *exclude_folders; char *dest_dir; char *local_filename; dlg_add_folder_save_last_options (data); if ((response == GTK_RESPONSE_CANCEL) || (response == GTK_RESPONSE_DELETE_EVENT)) { gtk_widget_destroy (data->dialog); return TRUE; } if (response == GTK_RESPONSE_HELP) { show_help_dialog (GTK_WINDOW (data->dialog), "engrampa-add-options"); return TRUE; } selected_folder = gtk_file_chooser_get_uri (file_sel); /* check folder permissions. */ if (! check_permissions (selected_folder, R_OK)) { GtkWidget *d; char *utf8_path; utf8_path = g_filename_display_name (selected_folder); d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL, NULL, _("Could not add the files to the archive"), _("You don't have the right permissions to read files from folder \"%s\""), utf8_path); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (utf8_path); g_free (selected_folder); return FALSE; } update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->add_if_newer_checkbutton)); recursive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->include_subfold_checkbutton)); follow_links = ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->exclude_symlinks)); include_files = gtk_entry_get_text (GTK_ENTRY (data->include_files_entry)); if (utf8_only_spaces (include_files)) include_files = "*"; exclude_files = gtk_entry_get_text (GTK_ENTRY (data->exclude_files_entry)); if (utf8_only_spaces (exclude_files)) exclude_files = NULL; exclude_folders = gtk_entry_get_text (GTK_ENTRY (data->exclude_folders_entry)); if (utf8_only_spaces (exclude_folders)) exclude_folders = NULL; local_filename = g_filename_from_uri (selected_folder, NULL, NULL); dest_dir = build_uri (fr_window_get_current_location (window), file_name_from_path (local_filename), NULL); fr_window_archive_add_with_wildcard (window, include_files, exclude_files, exclude_folders, selected_folder, dest_dir, update, follow_links); g_free (local_filename); g_free (dest_dir); g_free (selected_folder); gtk_widget_destroy (data->dialog); return TRUE; }
static void fr_command_jar_add (FrCommand *comm, const char *from_file, GList *file_list, const char *base_dir, gboolean update, gboolean recursive) { FrProcess *proc = comm->process; GList *zip_list = NULL, *jardata_list = NULL, *jar_list = NULL; GList *scan; char *tmp_dir; for (scan = file_list; scan; scan = scan->next) { char *filename = scan->data; char *path = build_uri (base_dir, filename, NULL); char *package = NULL; if (file_extension_is (filename, ".java")) package = get_package_name_from_java_file (path); else if (file_extension_is (filename, ".class")) package = get_package_name_from_class_file (path); if ((package == NULL) || (strlen (package) == 0)) zip_list = g_list_append (zip_list, g_strdup (filename)); else { JarData *newdata = g_new0 (JarData, 1); newdata->package_minus_one_level = remove_level_from_path (package); newdata->link_name = g_strdup (file_name_from_path (package)); newdata->rel_path = remove_level_from_path (filename); newdata->filename = g_strdup (file_name_from_path (filename)); jardata_list = g_list_append (jardata_list, newdata); } g_free (package); g_free (path); } tmp_dir = get_temp_work_dir (NULL); for (scan = jardata_list; scan ; scan = scan->next) { JarData *jdata = scan->data; char *pack_path; char *old_link; char *link_name; int retval; pack_path = build_uri (tmp_dir, jdata->package_minus_one_level, NULL); if (! make_directory_tree_from_path (pack_path, 0755, NULL)) { g_free (pack_path); continue; } old_link = build_uri (base_dir, jdata->rel_path, NULL); link_name = g_build_filename (pack_path, jdata->link_name, NULL); retval = symlink (old_link, link_name); if ((retval != -1) || (errno == EEXIST)) jar_list = g_list_append (jar_list, g_build_filename (jdata->package_minus_one_level, jdata->link_name, jdata->filename, NULL)); g_free (link_name); g_free (old_link); g_free (pack_path); } if (zip_list != NULL) parent_class->add (comm, NULL, zip_list, base_dir, update, FALSE); if (jar_list != NULL) parent_class->add (comm, NULL, jar_list, tmp_dir, update, FALSE); fr_process_begin_command (proc, "rm"); fr_process_set_working_dir (proc, "/"); fr_process_add_arg (proc, "-r"); fr_process_add_arg (proc, "-f"); fr_process_add_arg (proc, tmp_dir); fr_process_end_command (proc); fr_process_set_sticky (proc, TRUE); for (scan = jardata_list; scan ; scan = scan->next) { JarData *jdata = scan->data; g_free (jdata->filename); g_free (jdata->package_minus_one_level); g_free (jdata->link_name); g_free (jdata->rel_path); } path_list_free (jardata_list); path_list_free (jar_list); path_list_free (zip_list); g_free (tmp_dir); }