Hello,

I've triggered the Win32 'CreateFile()' file name length limit
in wget when downloading stuff generated by CGI from within a local
Windows directory with rather long path:

  cd /D C:\dir1\dir2\dir3\...   # e.g. path length of 57 chars.
  wget -nd -nc -r -A "*.cgi,*.bpx" \
    http://kal.bravolabs.com/kal/Album/624/5641/7267/BravoAlbum.html

The above wget eventually fails with:

  ...
  Cannot write to [EMAIL PROTECTED]' (No such file or
  directory).
  ...

because 'CreateFileA()' (ANSI version) called from 'gethttp() -> fopen()'
tries to create file that yields in absolute file name path (current
directory
+ relative file name argument) that is too long (> 260 chars -- see
'MAX_PATH'
in MSDN -> 'CreateFile()').

The problem could be fixed (to some extent) as follows:

Call 'CreateFileW()' (UNICODE version) with "\\?\" or " "\\?\UNC\" prefix
(see MSDN "File Name Conventions") instead of 'fopen()' in 'gethttp()'.

- convert file name argument from ANSI to UNICODE before passing it
  to 'CreateFileW()'
- handle/log possible Win32 'GetLastError()' error from 'CreateFileW()'
  instead of 'errno'

'CreateFileW()' (UNICODE) isn't available on Win9x/Me. Therefore,
wget would need to call either 'CreateFileA()' or 'CreateFileW()'
at run-time depending on target OS version.

So far I can live with the fact that I have to download long URLs to short
local directory names on Windows. Or I can download such stuff on Linux
and then transfer to Windows...

-- 
Radomir Tomis
[EMAIL PROTECTED]
Help stop world hunger -- visit <http://www.thehungersite.org>
Is The Hunger Site real? <http://www.umich.edu/~virus-busters/hunger.html>

Reply via email to