En Wed, 11 Mar 2009 11:59:57 -0200, venutaurus...@gmail.com
<venutaurus...@gmail.com> escribió:
On Mar 11, 6:41 pm, Tim Golden <m...@timgolden.me.uk> wrote:
venutaurus...@gmail.com wrote:
> On Mar 11, 5:19 pm, Tim Golden <m...@timgolden.me.uk> wrote:
Well, the source for os.chdir under Windows uses the Win32
SetCurrentDirectoryW API as expected. What is not expected
is that the MS docs for that function:
http://msdn.microsoft.com/en-us/library/aa365530(VS.85).aspx
still seem to suggest that you can't exceed MAX_PATH (ie 260)
characters. And indeed, attempting to do a mkdir at the command
line of something longer than that will also fail.
Hmmm.. maybe the usual advice for naming files \\?\... doesn't
apply to directory paths?
Do you have an already existing full pathname that long?
My application demands me to create deep paths of (1023) long.
I've cross checked it and the folder actually exists.
As TJG said, it appears that you can create such deep path, and create and
use files inside, but you can't chdir into it:
py> cien = '0123456789'*10
py> path = ur"\\?\c:\%s\%s\%s\%s\%s\%s\%s\%s\%s\%s\%s\%s" % ((cien,)*12)
py> len(path)
1218
py> os.mkdir(path) # after creating all intermediate directories
py> fn = os.path.join(path, 'x.txt')
py> f = open(fn, "w")
py> f.write("hello")
py> f.close()
py> open(fn).read()
'hello'
py> os.chdir(path)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
WindowsError: [Error 123] El nombre de archivo, directorio o etiqueta del
volume
n no es vßlido:
u'\\\\?\\c:\\012345678901234567890123456789012345678901234567890..."
So your application should always use absolute paths.
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list