file names longer than MAX_PATH under Windows 2003

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Feb 15 11:22:14 EST 2006


[Sergey]

| "Tim Golden" <tim.golden at viacom-outdoor.co.uk> wrote in 
| message news:mailman.1900.1139925147.27775.python-list at python.org...
| [Sergey]
| 
| >I see from another post that CreateFile cannot open your file.
| >That puts it further away from Python, although it doesn't
| >explain how some other program can see the files. Can you use
| >os.startfile (or its equivalent win32api.ShellExecute from
| >pywin32)? Perhaps if you were to chdir to the directory in
| >question you'd be able to access the file.
| 
| I found error in filename (extra backslash) and now I can open file.
| But another trouble appeared: I cannot listdir so long name.
| I examined posixmodule.c... There are wcsncpy with hard limit 
| of MAX_PATH*2+5.
| So... RIP, my module...

Have a look at win32file.FindFilesIterator from the pywin32 extensions.
Maybe that can cope? (I haven't looked at the source).

<code>
import win32file
for (
  attr, created, accessed, written, size_hi, size_lo, 
  _, _, 
  filename, alt_filename
) in win32file.FindFilesIterator ("c:/temp/*"):
  print filename

</code>

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list