static void do_upload (gftp_viewedit_data * ve_proc, gftp_dialog_data * ddata) { gftp_transfer * tdata; gftp_file * tempfle; GList * newfile; tempfle = g_malloc0 (sizeof (*tempfle)); tempfle->destfile = gftp_build_path (ve_proc->torequest, ve_proc->torequest->directory, ve_proc->remote_filename, NULL); ve_proc->remote_filename = NULL; tempfle->file = ve_proc->filename; ve_proc->filename = NULL; tempfle->done_rm = 1; newfile = g_list_append (NULL, tempfle); tdata = gftpui_common_add_file_transfer (ve_proc->fromwdata->request, ve_proc->torequest, ve_proc->fromwdata, ve_proc->towdata, newfile); free_edit_data (ve_proc); if (tdata != NULL) tdata->conn_error_no_timeout = 1; }
static int gftpui_common_cmd_chdir (void *uidata, gftp_request * request, void *other_uidata, gftp_request * other_request, const char *command) { gftpui_callback_data * cdata; char *tempstr, *newdir = NULL; if (!GFTP_IS_CONNECTED (request)) { request->logging_function (gftp_logging_error, request, _("Error: Not connected to a remote site\n")); return (1); } else if (*command == '\0') { request->logging_function (gftp_logging_error, request, _("usage: chdir <directory>\n")); return (1); } else if (request->protonum == GFTP_LOCAL_NUM) { if (*command != '/' && request->directory != NULL) { tempstr = gftp_build_path (request, request->directory, command, NULL); newdir = gftp_expand_path (request, tempstr); g_free (tempstr); } else newdir = gftp_expand_path (request, command); if (newdir == NULL) { request->logging_function (gftp_logging_error, request, _("usage: chdir <directory>\n")); return (1); } } cdata = g_malloc0 (sizeof (*cdata)); cdata->request = request; cdata->uidata = uidata; cdata->input_string = newdir != NULL ? newdir : (char *) command; cdata->run_function = gftpui_common_run_chdir; cdata->dont_clear_cache = 1; gftpui_common_run_callback_function (cdata); g_free (cdata); if (newdir != NULL) g_free (newdir); return (1); }
static GList * gftp_get_dir_listing (gftp_transfer * transfer, int getothdir, int *ret) { GHashTable * dirhash; GList * templist; gftp_file * fle; off_t *newsize; char *newname; if (getothdir && transfer->toreq != NULL) { dirhash = gftp_gen_dir_hash (transfer->toreq, ret); if (*ret == GFTP_EFATAL) return (NULL); } else dirhash = NULL; *ret = gftp_list_files (transfer->fromreq); if (*ret < 0) { gftp_destroy_dir_hash (dirhash); return (NULL); } fle = g_malloc0 (sizeof (*fle)); templist = NULL; while (gftp_get_next_file (transfer->fromreq, NULL, fle) > 0) { if (strcmp (fle->file, ".") == 0 || strcmp (fle->file, "..") == 0) { gftp_file_destroy (fle, 0); continue; } if (dirhash && (newsize = g_hash_table_lookup (dirhash, fle->file)) != NULL) { fle->exists_other_side = 1; fle->startsize = *newsize; } else fle->exists_other_side = 0; if (transfer->toreq && fle->destfile == NULL) fle->destfile = gftp_build_path (transfer->toreq, transfer->toreq->directory, fle->file, NULL); if (transfer->fromreq->directory != NULL && *transfer->fromreq->directory != '\0' && *fle->file != '/') { newname = gftp_build_path (transfer->fromreq, transfer->fromreq->directory, fle->file, NULL); g_free (fle->file); fle->file = newname; } templist = g_list_append (templist, fle); fle = g_malloc0 (sizeof (*fle)); } gftp_end_transfer (transfer->fromreq); gftp_file_destroy (fle, 1); gftp_destroy_dir_hash (dirhash); return (templist); }
static GList * _setup_current_directory_transfer (gftp_transfer * transfer, int *ret) { GHashTable * dirhash; char *pos, *newname; gftp_file * curfle; GList * lastlist; off_t *newsize; *ret = 0; if (transfer->toreq != NULL) { dirhash = gftp_gen_dir_hash (transfer->toreq, ret); if (*ret == GFTP_EFATAL) return (NULL); } else dirhash = NULL; for (lastlist = transfer->files; ; lastlist = lastlist->next) { curfle = lastlist->data; if ((pos = strrchr (curfle->file, '/')) != NULL) pos++; else pos = curfle->file; if (dirhash != NULL && (newsize = g_hash_table_lookup (dirhash, pos)) != NULL) { curfle->exists_other_side = 1; curfle->startsize = *newsize; } else curfle->exists_other_side = 0; if (curfle->size < 0 && GFTP_IS_CONNECTED (transfer->fromreq)) { curfle->size = gftp_get_file_size (transfer->fromreq, curfle->file); if (curfle->size == GFTP_EFATAL) { gftp_destroy_dir_hash (dirhash); *ret = curfle->size; return (NULL); } } if (transfer->toreq && curfle->destfile == NULL) curfle->destfile = gftp_build_path (transfer->toreq, transfer->toreq->directory, curfle->file, NULL); if (transfer->fromreq->directory != NULL && *transfer->fromreq->directory != '\0' && *curfle->file != '/') { newname = gftp_build_path (transfer->fromreq, transfer->fromreq->directory, curfle->file, NULL); g_free (curfle->file); curfle->file = newname; } if (lastlist->next == NULL) break; } gftp_destroy_dir_hash (dirhash); return (lastlist); }