[phobos] RFC: std.path

Rainer Schuetze r.sagitario at gmx.de
Tue Jun 14 14:09:36 PDT 2011


On 08.06.2011 21:29, Lars Tandle Kyllingstad wrote:
> As you may already know, I've had a new version of std.path in the works
> for a while.  It is ready now, and I am waiting for my turn in the
> review queue in the main NG.  In the meantime, I just thought I'd run it
> by this mailing list to iron out the worst wrinkles.
>
> So, if you feel like it, please comment.
>
> Code:
> https://github.com/kyllingstad/phobos/blob/std-path/std/path.d
>
> Docs:
> http://www.kyllingen.net/code/new-std-path/phobos-prerelease/std_path.html
>
>
> -Lars

Looks good to me. A few notes:

- I agree with Jose that toAbsolute and expandTilde feel a little 
out-of-place in this module as they are not only string manipulation 
functions.

- expandTilde is currently not implemented on windows, but I think a 
similar functionality using environment variables similar to HOME could 
work, too. I have no idea how to implement it for other users than the 
current, though.

- \\network drives are currently only respected under windows (at least 
that's what the documentation says). At work I'm using the same syntax 
on OSX to mount network drives (with forward slashes), so I guess it is 
also valid on Posix systems.

- isRelative and isAbsolute both return false on the empty string, while 
dirName("") returns ".". Wouldn't that imply that isRelative("") is true?

- when transferring data containing file names between different 
operating systems, it would be convenient to have the path operation of 
the other system available, too. While you can deal with posix file 
names on windows without big problems, the reverse is usually not the 
case (you have to convert backslashes manually, don't know how to strip 
drive names, etc). Would it be a good idea to have both versions 
accessible through namespaces, e.g. Posix.isRooted() and Win.isRooted(), 
and let the global functions dispatch to the implementation that fits 
the current OS?

Rainer


More information about the phobos mailing list