Message5223

Author jglick
Recipients Mahmoud, blix, mpm, pmezard
Date 2008-02-12.18:10:21
Content
Interesting indeed. Using Vista, I made a very long path - just repeat 'mkdir
0123456789' and 'cd 0123456789' until you get an error. 'mkdir morestuff' from
cmd.exe at this point fails. Yet using Python 2.5.1, I was able to

os.mkdir('\\\\?\\' + os.getcwd() + '\\morestuff')

and successfully create a subdir. Back in cmd.exe I could even cd into this
subdir, and open it in the Explorer, yet it was still impossible to create a new
text document in this folder using the context menu. (Trying to prepend \\?\ to
the path in the address bar had no effect.)

Furthermore, creating slightly longer directory names, or files using
open(...,'w').close(), did not work. It is worth noting some quite serious
caveats in

http://msdn2.microsoft.com/en-us/library/aa365247(VS.85).aspx

such as

"Relative paths are limited to MAX_PATH characters.

When using the API to create a directory, the specified path cannot be so long
that you cannot not append an 8.3 file name (MAX_PATH - 12).

The shell and the file system have different requirements. It is possible to
create a path with the API that the shell UI cannot handle."

In fact, it seems that the \\?\ trick only actually "buys" you a few more
characters, and is not a solution at all.
History
Date User Action Args
2008-02-12 18:10:21jglicksetmessageid: <1202839821.53.0.82621103085.issue839@selenic.com>
2008-02-12 18:10:21jglicksetrecipients: + mpm, pmezard, Mahmoud, blix
2008-02-12 18:10:21jglicklinkissue839 messages
2008-02-12 18:10:21jglickcreate