std.path review: second update

Jonathan M Davis jmdavisProg at gmx.com
Mon Aug 1 10:24:14 PDT 2011


> Here's a new update based on your comments and requests. Code and docs
> are in the usual place,
> 
> https://github.com/kyllingstad/phobos/blob/std-path/std/path.d
> http://www.kyllingen.net/code/std-path/phobos-prerelease/std_path.html
> 
> Here are the highlights:
> 
> * UNC paths, i.e. \\server\share\..., are now (hopefully) handled
> correctly on Windows. See the baseName(), dirName(), rootName(),
> driveName(), pathSplitter(), etc. docs for examples.
> 
> * Support for //foo/bar paths on POSIX has been removed.
> 
> * rootName() is new.
> 
> * pathSplitter() now returns a bidirectional range.
> 
> * pathCharMatch() and fcmp() have been replaced by improved functions
> filenameCharCmp() and filenameCmp(), respectively, with optional case
> sensitivity.
> 
> * joinPath() has been renamed to buildPath().
> 
> * Added a function buildNormalizedPath(), which performs normalization
> while joining the segments.
> 
> * Redefined normalize() in terms of buildNormalizedPath().
> 
> I am still unsure of the extent to which long UNC paths (i.e. \\?\...)
> should be supported, if at all. If anyone has anything to say on the
> matter, please do. :)

Well, my previous comments on function names still stand - both in terms of 
names using Ext instead of Extension and Sep instead of sep - and also with 
regards to making non-property functions verbs (e.g. absolutePath and 
relativePath).

Aside from that, wasn't it discussed that extensions should include the . in 
them in order to cover the case where a file ends in a .? Otherwise

assert(extension("file.") == extension("file"));

So, all of the stuff dealing with extensions should probably include the dot 
in the extension. It looks like both the current std.path and your std.path 
handle it by using "" for dot and null for nothing, but distinguishing between 
null and the empty string like that isn't necessarily a good idea, and your 
documentation doesn't make the distinction clear, unlike the documentation for 
the current std.path.

So, at minimum, the docs should be clearer about null vs empty when it comes 
to the extension (and there should be tests for it), but it would arguably be 
better to just include the . in the extension.

- Jonathan M Davis


More information about the Digitalmars-d mailing list