[phobos] std.path proof of concept

Steve Schveighoffer schveiguy at yahoo.com
Fri Apr 23 08:23:49 PDT 2010


I would make a suggestion that the Windows version allows forward slash for a dir separator as input.  "C:/foo/bar.txt" and "C:\\foo/bar.txt" are both valid paths on Windows.

-Steve



----- Original Message ----
> From: Lars Tandle Kyllingstad <lars at kyllingen.net>
> To: Phobos mailing list <phobos at puremagic.com>
> Sent: Fri, April 23, 2010 10:51:12 AM
> Subject: [phobos] std.path proof of concept
> 
> I am convinced that what I've proposed is a good idea, so I made a tiny 
> proof-of-concept version of the module.

In fact, I found an even better 
> way to do it:  Instead of putting the functions inside structs, I just have 
> one template of which the appropriate instantiation is mixed into the module 
> scope.  So, on Windows,

    
> getDirectory("c:\\foo\\bar.txt")         -->  
> "c:\\foo"
    Path!Posix.getDirectory("/foo/bar.txt")  
> -->  "/foo"

In this way, there is no code duplication and no more 
> work for the library maintainer, only more flexibility for the user.  Check 
> out the code and documentation if you don't believe me:

  
> http://github.com/kyllingstad/ltk/blob/master/ltk/path.d
  
> http://kyllingen.net/code/ltk/doc/path.html


-Lars
_______________________________________________
phobos 
> mailing list

> href="mailto:phobos at puremagic.com">phobos at puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos


      


More information about the phobos mailing list