I have a few suggestions for improvements to std.path, and if people agree, I'll be happy to implement them:

1. Cross-platform path handling:

Since most of std.path only deals with strings, and therefore doesn't perform any OS-specific operations, there is really no reason to completely hide the Windows path handling stuff from POSIX users and vice versa.

I therefore propose to put the Windows stuff in a WindowsPath namespace and the POSIX stuff in a PosixPath namespace, implemented as structs with only static members.

The module-level functions stay -- after all, a POSIX user will want to deal with POSIX paths most of the time -- but now as aliases of either PosixPath or WindowsPath member functions, depending on which OS the library is compiled for.


2. Consistent naming:

  sep       -> dirSeparator
  pathsep   -> pathSeparator
  isabs()   -> isAbsolute()
  rel2abs() -> toAbsolute()
  getExt()  -> extension()


3. Add some useful stuff, like the toCanonical() function I have in my personal library (it's like rel2abs, except it also resolves ../ and ./).


4. Change the type of sep, altsep, etc. to immutable string. (Or is there a good reason why they're all _static_ arrays?)


5. Get rid of the legacy stuff (specifically, the getBaseName and getDirName aliases). Now's a good a time as any.


6. Fix bugs. Some are in Bugzilla, and there are a couple which I've found quite recently but haven't gotten around to reporting yet:

  * join("", "foo") returns "/foo", should be "foo".

  * On POSIX, getExt("/tmp/.foo") returns "foo", should be ""
    (it's the name of a hidden file, not an extension).



Whatcha think?

-Lars
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to