std.path.getName(): Screwy by design?

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Tue Mar 1 05:11:27 PST 2011


On Tue, 01 Mar 2011 07:48:56 -0500, Nick Sabalausky wrote:

> "Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> wrote in message
> news:ikiktf$2vba$3 at digitalmars.com...
>>
>> I would like to say, however, that I think 'sep' is almost up there
>> with rel2abs in terms of bad naming.  If you just see 'sep' in a piece
>> of code, maybe you understand it is a separator, but I don't think
>> everyone will conclude it is a directory separator.  Using the fully
>> qualified name 'std.path.sep' isn't good either, because now it looks
>> like it's a path separator.
>>
>>
> Speaking of sep, I've never been entirely happy with std.path's tendency
> to encourage the use of platform-specific directory separators. Windows
> generally handles forward-slash just fine, so I've always felt it best
> to always just use forward-slash, and then convert to backslash
> as-needed in the very rare cases where it actually matters.
> 
> Doing either std.path.join("..", "dir", "subdir", "file") or
> ".."~sep~"dir"~sep~"subdir"~sep~"file" is fucking butt-ugly, and it's
> useless anyway since "../dir/subdir/file" works just fine on all OSes
> including Windows. (Obviously sep should still exist, regardless of what
> it's named. But, at least judging by the docs, std.path just seems to
> rely on it too much.)

This was discussed on the Phobos mailing list a while ago, and Walter 
said that using forward-slash often doesn't work on Windows:

  http://lists.puremagic.com/pipermail/phobos/2010-April/000309.html

I don't use Windows much myself, so I don't know.

-Lars


More information about the Digitalmars-d mailing list