[phobos] RFC: std.path

Jose Armando Garcia jsancio at gmail.com
Sun Jun 12 09:36:52 PDT 2011


On Sun, Jun 12, 2011 at 12:59 PM, Lars Tandle Kyllingstad
<lars at kyllingen.net> wrote:
> On Sun, 2011-06-12 at 12:41 -0300, Jose Armando Garcia wrote:
>> On Sun, Jun 12, 2011 at 12:15 PM, Lars Tandle Kyllingstad
>> <lars at kyllingen.net> wrote:
>> > On Sun, 2011-06-12 at 11:39 -0300, Jose Armando Garcia wrote:
>> >> On Wed, Jun 8, 2011 at 4:29 PM, Lars Tandle Kyllingstad
>> > These functions are from the old std.path, and I haven't made any
>> > changes to them in my version.
>> >
>> > - toAbsolute()
>> > - toCanonical()
>> >
>>
>> In the comments where you say that it doesn't perform any IO you
>> should add these functions.
>
> Does getcwd() perform any IO on Windows?  AFAIK, on POSIX it just
> queries /proc/self/cwd, which is a virtual file.
>

The way I look at IO is anything that is external to the process.
Another way to thinking about it is that
toAbsolute()'s and toCanonical()'s result is dependent on state
outside of the process. While the rest of the templates/functions
aren't.

>
>> Speaking of which can we add a template
>> called normalize (maybe you can come up with a better name) that does
>> what canonical does but doesn't make it absolute. E.g.:
>>
>> version(windows) assert(normilize("dir/file") == "dir\\file");
>> version(windows) assert(normilize("dir/./file") == "dir\\file");
>> //etc
>
> That sounds like a good idea.  Then I guess normalize("../foo") should
> just return "..\\foo", i.e. leave the ".." unresolved?
>

It is hard to resolve '..' without looking at the file system when
considering soft/sym link due to multiple parents. if 'somedir' is a
simlink "somedir/../" != ".".


More information about the phobos mailing list