1
|
1 /*****************************************************************************/
|
|
2 /* mkdir_dialog.c - make directory dialog box and ftp routines */
|
|
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */
|
|
4 /* */
|
|
5 /* This program is free software; you can redistribute it and/or modify */
|
|
6 /* it under the terms of the GNU General Public License as published by */
|
|
7 /* the Free Software Foundation; either version 2 of the License, or */
|
|
8 /* (at your option) any later version. */
|
|
9 /* */
|
|
10 /* This program is distributed in the hope that it will be useful, */
|
|
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
13 /* GNU General Public License for more details. */
|
|
14 /* */
|
|
15 /* You should have received a copy of the GNU General Public License */
|
|
16 /* along with this program; if not, write to the Free Software */
|
|
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
|
|
18 /*****************************************************************************/
|
|
19
|
|
20 #include "gftp-gtk.h"
|
|
21
|
|
22 static const char *edttext;
|
|
23 static sigjmp_buf mkdirenvir;
|
|
24
|
|
25
|
19
|
26 static RETSIGTYPE
|
|
27 sig_mkdirquit (int signo)
|
1
|
28 {
|
19
|
29 signal (signo, sig_mkdirquit);
|
|
30 siglongjmp (mkdirenvir, signo == SIGINT ? 1 : 2);
|
1
|
31 }
|
|
32
|
|
33
|
|
34 static void *
|
|
35 do_make_dir_thread (void * data)
|
|
36 {
|
|
37 gftp_window_data * wdata;
|
|
38 int success, sj;
|
|
39
|
|
40 wdata = data;
|
|
41 wdata->request->user_data = (void *) 0x01;
|
|
42
|
|
43 if (wdata->request->use_threads)
|
|
44 {
|
|
45 sj = sigsetjmp (mkdirenvir, 1);
|
|
46 signal (SIGINT, sig_mkdirquit);
|
|
47 signal (SIGALRM, sig_mkdirquit);
|
|
48 }
|
|
49 else
|
|
50 sj = 0;
|
|
51
|
|
52 success = 0;
|
|
53 if (sj == 0)
|
|
54 {
|
|
55 if (wdata->request->network_timeout > 0)
|
|
56 alarm (wdata->request->network_timeout);
|
|
57 success = gftp_make_directory (wdata->request, edttext) == 0;
|
|
58 alarm (0);
|
|
59 }
|
|
60 else
|
|
61 {
|
|
62 gftp_disconnect (wdata->request);
|
|
63 wdata->request->logging_function (gftp_logging_error,
|
|
64 wdata->request->user_data,
|
|
65 _("Operation canceled\n"));
|
|
66 }
|
|
67
|
|
68 if (wdata->request->use_threads)
|
|
69 {
|
|
70 signal (SIGINT, SIG_DFL);
|
|
71 signal (SIGALRM, SIG_IGN);
|
|
72 }
|
|
73
|
|
74 wdata->request->user_data = NULL;
|
|
75 wdata->request->stopable = 0;
|
|
76 return ((void *) success);
|
|
77 }
|
|
78
|
|
79
|
19
|
80 static void
|
|
81 domkdir (gftp_window_data * wdata, gftp_dialog_data * ddata)
|
1
|
82 {
|
19
|
83 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
|
|
84 if (*edttext == '\0')
|
|
85 {
|
|
86 ftp_log (gftp_logging_misc, NULL,
|
|
87 _("Mkdir: Operation canceled...you must enter a string\n"));
|
|
88 return;
|
|
89 }
|
|
90
|
|
91 if (check_reconnect (wdata) < 0)
|
|
92 return;
|
|
93
|
|
94 if ((int) generic_thread (do_make_dir_thread, wdata))
|
|
95 {
|
|
96 gftp_delete_cache_entry (wdata->request);
|
|
97 refresh (wdata);
|
|
98 }
|
1
|
99 }
|
|
100
|
19
|
101
|
|
102 void
|
|
103 mkdir_dialog (gpointer data)
|
|
104 {
|
|
105 gftp_window_data * wdata;
|
|
106
|
|
107 wdata = data;
|
|
108 if (!check_status (_("Mkdir"), wdata, wdata->request->use_threads, 0, 0,
|
|
109 wdata->request->mkdir != NULL))
|
|
110 return;
|
|
111
|
|
112 MakeEditDialog (_("Make Directory"), _("Enter name of directory to create"),
|
|
113 NULL, 1, NULL, gftp_dialog_button_create, domkdir, wdata,
|
|
114 NULL, NULL);
|
|
115 }
|
|
116
|