aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Durner <durner@gnunet.org>2005-08-28 13:18:47 +0000
committerNils Durner <durner@gnunet.org>2005-08-28 13:18:47 +0000
commit398f558277ea607ae9101aae32b702a1b17ba260 (patch)
treeb83dba27b9df4839b445cf5323fc6aee770802e2
parent516243f86c26e78c889b0ca489e9f93709424187 (diff)
downloadgnunet-gtk-398f558277ea607ae9101aae32b702a1b17ba260.tar.gz
gnunet-gtk-398f558277ea607ae9101aae32b702a1b17ba260.zip
improve workaround for MAX_PATH issue
-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,