Exceeding the windows API MAX_PATH limit

Adrian Buehlmann adrian at cadifra.com
Fri Apr 20 11:39:47 CDT 2012


On 2012-04-20 18:08, Laurens Holst wrote:
> Op 20-04-12 16:44, Adrian Buehlmann schreef:
>> On 2012-04-20 14:48, Noel Grandin wrote:
>>> On 2012-04-20 14:42, Adrian Buehlmann wrote:
>>>> And how do you plan to handle these files with Explorer?
>>> subst.exe
>> subst won't help with deleting files with reserved names at all and I
>> can easily construct paths with lengths where even subst won't be able
>> to help anymore.
> 
> Explorer can not handle them, but can’t del and rmdir on the command line?

Nope. See transcript below:

Show current directory

    $ cd
    C:\Users\adi\mercurial\tmp

Creating a file with a reserved name using cmd.exe is no problem using
long path API trigger ("\\?\")

    $ echo bla > \\?\C:\Users\adi\mercurial\tmp\aux.txt

    $ dir
     Volume in drive C has no label.
     Volume Serial Number is F80E-0A52

     Directory of C:\Users\adi\mercurial\tmp

    20.04.2012  18:19    <DIR>          .
    20.04.2012  18:19    <DIR>          ..
    20.04.2012  18:19                 6 aux.txt
                   1 File(s)              6 bytes
                   2 Dir(s)  383'447'584'768 bytes free

del fails

    $ del aux.txt
    The filename, directory name, or volume label syntax is incorrect.

del with long path API trigger hangs forever:

    $ del \\?\C:\Users\adi\mercurial\tmp\aux.txt
    \\?\C:\Users\adi\mercurial\tmp\aux.txt
    The I/O operation has been aborted because of either a thread exit
or an application request.

I've aborted the last operation after waiting for ~20 seconds.

Of course, delete using Explorer failed too, bickering about problems
with permission (even so after admin-UAC promt).

Tested on Windows 7 x64.

(For help with getting rid of such files see:
https://bitbucket.org/abuehl/winrm)




More information about the Mercurial-devel mailing list