----- Original Message ----
> From: Andrei Alexandrescu <[email protected]>
> To: Discuss the phobos library for D <[email protected]>
> Sent: Mon, January 3, 2011 10:43:27 AM
> Subject: Re: [phobos] next release (meaning of path)
>
> On 1/3/11 6:42 AM, Steve Schveighoffer wrote:
> > Would it be enough to have a function that takes a string (or
> > inout(char)[]
>if
> > possible) and returns a string[] with the path elements? Also, a function
>to do
> > the reverse.
>
> Problem is I've seldom been in a situation in life where I could find use
> for
>such a function. Most of the time I want basename, dirname, and if applicable
>drive. I don't want to dissect the entire dirname.
What about a breadcrumb trail? Or trying to determine if there is a '..' in
the
path?
In any case, the point of the function is to remove all OS-specific
information,
leaving the directory intact retains those pesky dir separators. A path in
array form is easier to deal with in an OS-agnostic way. Plus, an array is
immediately available to perform any algorithmic functions on it (for instance,
searching for a '..').
It's worth noting that getting the full directory and an array of the directory
names is in direct conflict (not intuitive to have an API that provides both
with the same function). This might argue for having a Path type where you
could have more flexibility. Or you could just provide multiple functions.
Either way, path manipulation is one of those things IMO that pops up
infrequently. Generally you just want to pass around the entire path, and you
don't care what's in it.
-Steve
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos