diff options
author | Christian Grothoff <christian@grothoff.org> | 2006-03-18 20:33:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2006-03-18 20:33:35 +0000 |
commit | 47fa0355dbe3795a934e7f8789e36fa501083d5f (patch) | |
tree | e9e189ee64fecb845fd9ea8b02e795907166b5e3 | |
parent | 04552ebfb969ab9e74a82b94cede71b960eb2212 (diff) | |
download | gnunet-gtk-47fa0355dbe3795a934e7f8789e36fa501083d5f.tar.gz gnunet-gtk-47fa0355dbe3795a934e7f8789e36fa501083d5f.zip |
fix
-rw-r--r-- | src/plugins/fs/download.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index 3a9c4e06..caa27695 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -119,7 +119,10 @@ static void initiateDownload(GtkTreeModel * model, | |||
119 | GtkTreeIter iiter; | 119 | GtkTreeIter iiter; |
120 | GtkWidget * spin; | 120 | GtkWidget * spin; |
121 | const char * name; | 121 | const char * name; |
122 | const char * oname; | ||
123 | const char * cname; | ||
122 | const char * mime; | 124 | const char * mime; |
125 | char * dname; | ||
123 | unsigned int anon; | 126 | unsigned int anon; |
124 | GtkTreePath *dirTreePath; | 127 | GtkTreePath *dirTreePath; |
125 | char *dirPath; | 128 | char *dirPath; |
@@ -174,21 +177,51 @@ static void initiateDownload(GtkTreeModel * model, | |||
174 | return; | 177 | return; |
175 | } | 178 | } |
176 | 179 | ||
177 | if (name == NULL) | 180 | if (name == NULL) { |
178 | #ifdef WINDOWS | 181 | #ifdef WINDOWS |
179 | { | ||
180 | filehash = STRDUP(uri_name); | 182 | filehash = STRDUP(uri_name); |
181 | filehash[16] = 0; | 183 | filehash[16] = 0; |
182 | name = filehash; | 184 | name = filehash; |
183 | } | ||
184 | #else | 185 | #else |
185 | name = uri_name; | 186 | name = uri_name; |
186 | #endif | 187 | #endif |
188 | } | ||
189 | |||
190 | cname = name; | ||
191 | oname = name; | ||
192 | dname = MALLOC(strlen(name)+1); | ||
193 | dname[0] = '\0'; | ||
194 | while (*name != '\0') { | ||
195 | if ( (*name == DIR_SEPARATOR) && | ||
196 | (name[1] != '\0') ) { | ||
197 | memcpy(dname, oname, name - oname); | ||
198 | dname[name - oname] = '\0'; | ||
199 | cname = &name[1]; | ||
200 | } | ||
201 | name++; | ||
202 | } | ||
203 | if (*cname == '\0') /* name ended in '/' - likely directory */ | ||
204 | cname = oname; | ||
205 | name = cname; | ||
187 | 206 | ||
188 | final_download_dir = getFileName("FS", | 207 | final_download_dir = getFileName("FS", |
189 | "INCOMINGDIR", | 208 | "INCOMINGDIR", |
190 | _("You must specify a directory in the configuration" | 209 | _("You must specify a directory in the configuration" |
191 | " in section `%s' under `%s'.")); | 210 | " in section `%s' under `%s'.")); |
211 | if (strlen(dname) > 0) { | ||
212 | char * tmp; | ||
213 | tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); | ||
214 | strcpy(tmp, final_download_dir); | ||
215 | if (tmp[strlen(tmp)] != DIR_SEPARATOR) | ||
216 | strcat(tmp, DIR_SEPARATOR_STR); | ||
217 | if (dname[0] == DIR_SEPARATOR) | ||
218 | strcat(tmp, &dname[1]); | ||
219 | else | ||
220 | strcat(tmp, dname); | ||
221 | FREE(final_download_dir); | ||
222 | final_download_dir = tmp; | ||
223 | } | ||
224 | FREE(dname); | ||
192 | mkdirp(final_download_dir); | 225 | mkdirp(final_download_dir); |
193 | 226 | ||
194 | 227 | ||