Boost logo

Boost :

Subject: Re: [boost] Making Boost.Filesystem work with GENERAL filenames with g++ in Windows (a solution)
From: Alf P. Steinbach (alf.p.steinbach+usenet_at_[hidden])
Date: 2011-10-26 11:30:28

On 26.10.2011 16:57, Dave Abrahams wrote:
> on Wed Oct 26 2011, "Alf P. Steinbach"<> wrote:
>> Those long paths can't be handled by Windows Explorer or most other
>> software. Therefore, adding an ability to use them inadvertently, is
>> at best strongly misguided. It would encourage novice developers to
>> create files that ordinary users can't delete, move or rename.
>> The world has 26 years of Windows usage without such long paths, even
>> after they were introduced in 1993.
>> So with 26 years of not needing them going on strong, and 18 years of
>> not being used (by anyone other than script kiddies) despite being
>> there, it is an established fact any competent developer don't need
>> them and won't use them. And also, it is an established fact that
>> using them creates trouble for the users. Don't even think about it
>> -- and here I'm not talking about Boost, but about your own efforts.
> Suppose you want to write a utility to clean up such paths in the
> filesystem? If they can't be represented, there's a problem, neh?

No problem: it would be a Windows-specific program, and also a rather
small one, so use of the Windows API would be OK.

I think what you're saying is that ideally Boost should support the full
functionality of the native system.

But Boost isn't doing that. And when the full functionality is not
generally supported even by the vendor (Microsoft), it is a bit
dangerous to support it. Because other software will not be able to
handle it, and that includes e.g. the standard library of g++.


Also, when I have cleaned up such files and folders in Windows, I have
just used the command interpreter.

E.g., "con" is a reserved device name (the console) and cannot usually
be used to name a file or folder. But \\.\ or \\?\, I can't remember
which, is like a "raw path". So,

d:\> md dave

d:\> cd dave

d:\dave> md \\.\d:\dave\con

d:\dave> dir
  Volume in drive D is DATA
  Volume Serial Number is A875-F9FD

  Directory of d:\dave

26.10.2011 17:24 <DIR> .
26.10.2011 17:24 <DIR> ..
26.10.2011 17:24 <DIR> con
                0 File(s) 0 bytes
                3 Dir(s) 233 918 234 624 bytes free

d:\dave> rd con
The system cannot find the file specified.

d:\dave> rd \\.\d:\dave\con

d:\dave> _

Of course I shouldn't really have shown such trick here, where I have
impression that perhaps script kiddies lurking, but hey, it's my
birthday. :-)

Anyway, other tricks to handle troublesome paths include conversion to
shortname form (the fix that I'm proposing to let Boost.Filesystem work
with g++), which you can easily do using 'for' command, and using e.g.
'subst' command to define a logical drive for a directory in the path.


- Alf

Boost list run by bdawes at, gregod at, cpdaniel at, john at