aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/download.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/download.c')
-rw-r--r--src/plugins/fs/download.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c
index 3a36d4ed..7918168f 100644
--- a/src/plugins/fs/download.c
+++ b/src/plugins/fs/download.c
@@ -124,6 +124,9 @@ static void initiateDownload(GtkTreeModel * model,
124 GtkTreePath *dirTreePath; 124 GtkTreePath *dirTreePath;
125 char *dirPath; 125 char *dirPath;
126 unsigned int dirPathLen; 126 unsigned int dirPathLen;
127#ifdef WINDOWS
128 unsigned int downDirLen;
129#endif
127 130
128 uri = NULL; 131 uri = NULL;
129 meta = NULL; 132 meta = NULL;
@@ -192,6 +195,9 @@ static void initiateDownload(GtkTreeModel * model,
192 "DOWNLOADDIR", 195 "DOWNLOADDIR",
193 _("You must specify a directory in the configuration" 196 _("You must specify a directory in the configuration"
194 " in section `%s' under `%s'.")); 197 " in section `%s' under `%s'."));
198#ifdef WINDOWS
199 downDirLen = strlen(fn);
200#endif
195 mkdirp(fn); 201 mkdirp(fn);
196 pfx = MALLOC(strlen(fn) + 2 + 202 pfx = MALLOC(strlen(fn) + 2 +
197 strlen(name)); 203 strlen(name));
@@ -208,23 +214,39 @@ static void initiateDownload(GtkTreeModel * model,
208 DIR_SEPARATOR_STR); 214 DIR_SEPARATOR_STR);
209 strcat(pfx, 215 strcat(pfx,
210 name); 216 name);
211#ifndef WINDOWS
212 strcat(lnk, 217 strcat(lnk,
213 &filename[strlen(ECRS_URI_PREFIX) + 218 &filename[strlen(ECRS_URI_PREFIX) +
214 strlen(ECRS_FILE_INFIX)]); 219 strlen(ECRS_FILE_INFIX)]);
215#else 220#ifdef WINDOWS
216 { 221 {
217 /* Do not exceed MAX_PATH under Windows */ 222 /* Do not exceed MAX_PATH under Windows
223 The longest path we get is
224 $DOWNLOADDIR\hash.lnk
225 or
226 $INCOMINGDIR\hash.lnk
227
228 We truncate the hash here accordingly. */
229
230 int diff; /* How much is INCOMINGDIR larger than DOWNLOADDIR */
231 char *inc = getFileName("FS",
232 "INCOMINGDIR",
233 _("You must specify a directory in the configuration"
234 " in section `%s' under `%s'."));
235
236 diff = downDirLen - strlen(inc);
237 if (diff < 0)
238 diff = 0;
218 239
219 int fnlen = MAX_PATH - strlen(lnk) - 4; /* 4 = ".lnk"*/ 240 FREE(inc);
220 if (fnlen < 4) { 241
242 char *end = lnk + MAX_PATH - 5 - diff; /* 4 = ".lnk" */
243
244 *end = 0;
245
246 if (strchr(end + 1, DIR_SEPARATOR)) {
221 BREAK(); 247 BREAK();
222 return; 248 return;
223 } 249 }
224
225 strncat(lnk,
226 &filename[strlen(ECRS_URI_PREFIX) +
227 strlen(ECRS_FILE_INFIX)], fnlen);
228 } 250 }
229#endif 251#endif
230 if (0 != STAT(pfx, 252 if (0 != STAT(pfx,