diff options
Diffstat (limited to 'src/plugins/fs/download.c')
-rw-r--r-- | src/plugins/fs/download.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index 7918168f..af4e32ed 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -119,6 +119,7 @@ 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 * mime; | ||
122 | struct stat sbuf; | 123 | struct stat sbuf; |
123 | unsigned int anon; | 124 | unsigned int anon; |
124 | GtkTreePath *dirTreePath; | 125 | GtkTreePath *dirTreePath; |
@@ -131,11 +132,13 @@ static void initiateDownload(GtkTreeModel * model, | |||
131 | uri = NULL; | 132 | uri = NULL; |
132 | meta = NULL; | 133 | meta = NULL; |
133 | name = NULL; | 134 | name = NULL; |
135 | mime = NULL; | ||
134 | gtk_tree_model_get(model, | 136 | gtk_tree_model_get(model, |
135 | iter, | 137 | iter, |
136 | SEARCH_NAME, &name, | 138 | SEARCH_NAME, &name, |
137 | SEARCH_URI, &uri, | 139 | SEARCH_URI, &uri, |
138 | SEARCH_META, &meta, | 140 | SEARCH_META, &meta, |
141 | SEARCH_MIME, &mime, | ||
139 | -1); | 142 | -1); |
140 | if (uri == NULL) { | 143 | if (uri == NULL) { |
141 | BREAK(); | 144 | BREAK(); |
@@ -200,7 +203,7 @@ static void initiateDownload(GtkTreeModel * model, | |||
200 | #endif | 203 | #endif |
201 | mkdirp(fn); | 204 | mkdirp(fn); |
202 | pfx = MALLOC(strlen(fn) + 2 + | 205 | pfx = MALLOC(strlen(fn) + 2 + |
203 | strlen(name)); | 206 | strlen(name) + 4); /* 4 = ".gnd" */ |
204 | lnk = MALLOC(strlen(fn) + 2 + | 207 | lnk = MALLOC(strlen(fn) + 2 + |
205 | strlen(filename)); | 208 | strlen(filename)); |
206 | strcpy(pfx, fn); | 209 | strcpy(pfx, fn); |
@@ -217,6 +220,18 @@ static void initiateDownload(GtkTreeModel * model, | |||
217 | strcat(lnk, | 220 | strcat(lnk, |
218 | &filename[strlen(ECRS_URI_PREFIX) + | 221 | &filename[strlen(ECRS_URI_PREFIX) + |
219 | strlen(ECRS_FILE_INFIX)]); | 222 | strlen(ECRS_FILE_INFIX)]); |
223 | |||
224 | /* Append ".gnd" if needed */ | ||
225 | if (mime && strcmp(mime, "application/gnunet-directory") == 0) { | ||
226 | int len = strlen(pfx); | ||
227 | if (len > 5 && strcmp(pfx + len - 5, ".gnd") != 0) { | ||
228 | char *end = pfx + len - 1; | ||
229 | if (*end == '/' || *end == '\\') | ||
230 | *end = 0; | ||
231 | } | ||
232 | strcat(pfx, ".gnd"); | ||
233 | } | ||
234 | |||
220 | #ifdef WINDOWS | 235 | #ifdef WINDOWS |
221 | { | 236 | { |
222 | /* Do not exceed MAX_PATH under Windows | 237 | /* Do not exceed MAX_PATH under Windows |