Tim Rühsen <tim.rueh...@gmx.de> writes: > Some people stumbled upon the _PC_NAME_MAX stuff when compiling for Windows. > Just search the last 2 months for '_PC_NAME_MAX'.
Thanks. I have cherry-picked this part of the change into master, I have pushed this patch, it is a subset of the patch that was originally sent for parallel-wget: >From 9d35f8721839931ebd3cec9721dca03267764463 Mon Sep 17 00:00:00 2001 From: Ray Satiro <raysat...@yahoo.com> Date: Tue, 21 May 2013 18:06:25 -0400 Subject: [PATCH] MinGW compatibility fixes --- src/ChangeLog | 4 ++++ src/url.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index f609698..4021d9c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2013-05-21 Ray Satiro <raysat...@yahoo.com> + + * url.c (url_file_name): Use MAX_PATH in Windows. + 2013-06-13 Darshit Shah <dar...@gmail.com> * http.c (gethttp): Follow RFC 2616 and httpbis specifications when diff --git a/src/url.c b/src/url.c index 87d6290..5e2b9a3 100644 --- a/src/url.c +++ b/src/url.c @@ -1617,7 +1617,26 @@ url_file_name (const struct url *u, char *replaced_filename) append_char ('\0', &temp_fnres); /* Check that the length of the file name is acceptable. */ +#ifdef WINDOWS + if (MAX_PATH > (fnres.tail + CHOMP_BUFFER + 2)) + { + max_length = MAX_PATH - (fnres.tail + CHOMP_BUFFER + 2); + /* FIXME: In Windows a filename is usually limited to 255 characters. + To really be accurate you could call GetVolumeInformation() to get + lpMaximumComponentLength + */ + if (max_length > 255) + { + max_length = 255; + } + } + else + { + max_length = 0; + } +#else max_length = get_max_length (fnres.base, fnres.tail, _PC_NAME_MAX) - CHOMP_BUFFER; +#endif if (max_length > 0 && strlen (temp_fnres.base) > max_length) { logprintf (LOG_NOTQUIET, "The name is too long, %lu chars total.\n", -- 1.8.1.4 -- Giuseppe