Next in Review Queue: The New std.path

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Fri Jul 15 08:54:13 PDT 2011


On Fri, 15 Jul 2011 04:33:34 -0400, Nick Sabalausky wrote:

> "dsimcha" <dsimcha at yahoo.com> wrote in message
> news:ivo1ef$1ero$1 at digitalmars.com...
>> Lars Kyllingstad's new and improved std.path module for Phobos is the
>> next item up in the review queue.
>>
>>
> Yay!
> 
> First of all, very well-written docs :)

Thanks! :)

 
> My notes:
> 
> - For clarity and completeness, the docs for joinPath should include the
> example:
> 
> joinPath("foo", "bar");
> 
> It does already have joinPath(r"c:\foo", "bar"), but it's easy to
> overlook the fact that's demonstrating the same thing, especially if
> you're more interested in Posix.

Good point.


> - For generic purposes, maybe joinPath should accept being called with
> just one argument? If it already does, then the "Joins two or more path
> components" should change to "Joins one or more path components"

I'll look into it.

 
> - Maybe there should be a function canonical() that resolves symbolic
> links, runs absolutePath() and normalize(), and on Windows converts to
> lowercase. Doesn't need to be in there right now though, could wait for
> a later release.

I'd be more in favour of adding a resolveSymLinks function to std.file.  
In any case, I'd prefer it not be part of this proposal, and rather be 
added later.


> - Docs don't say how pathCharMatch handles slash and backslash.

True, I'll fix.


> - I really hate to bring up a function-naming issue at this point, but
> "glob" is commonly known to mean "Return all existing files/paths that
> match this pattern" (And that's something we should have at some point,
> btw, if we don't already). So maybe this glob should be called something
> like globMatch or matchGlob instead.
> 
> - I don't think I like how glob works. It doesn't seem to know anything
> about directory separators, which seems unintuitive and problematic. I'd
> really like to see it work like this (basically from Ruby):
> 
> assert( glob("dir/foo", "dir/*") );
> assert( glob("dir/foo", "dir/**") );
> 
> assert( !glob("dir/foo/bar", "dir/*") ); assert( glob("dir/foo/bar",
> "dir/**") );
> 
> assert( glob("dir/foo/abc", "dir/*/abc") ); assert( glob("dir/foo/abc",
> "dir/**/abc") );
> 
> assert( !glob("dir/foo/bar/abc", "dir/*/abc") ); assert(
> glob("dir/foo/bar/abc", "dir/**/abc") );
> 
> assert( glob("dir/foo", "dir/f*o") ); assert( !glob("dir/faa/boo",
> "dir/f*o") );
> 
> As it is right now, how would you do a non-recursive star-match? Doesn't
> look like you even can.

I haven't done anything to glob (i.e. fnmatch in the current std.path) 
except change its name and improve its documentation.  For all intents 
and purposes, it is not part of my submission.  If I find the time, 
however, I'll look into improving it.

-Lars


More information about the Digitalmars-d mailing list