[phobos] next release (meaning of path)

Jonathan M Davis jmdavisProg at gmx.com
Mon Jan 3 15:13:11 PST 2011


On Monday 03 January 2011 14:42:01 Jesse Phillips wrote:
> I do not know of a good reason for having a Path type. However I do
> believe much can be added to help with manipulated paths. Here are
> some issues I've had.
> 
> * Converting to the proper sep
> * getBaseName(getName(file)) will give just the filename and no path
> when there is no extension, switching the calls gives you nothing.
> * A quoted path is sometimes valid, and some times not. Namely making
> system calls needs the quotes or escaped spaces, while std.file
> expects none of that.
> * It should be easy to convert one OS path style to another. (Ignoring
> drive letter)

A fancier feature would be to have a function which converts a file name to one 
which is valid for the current OS. Which characters are valid does vary somewhat 
from file system to file system, but it's OS-specific enough that it can be done. 
Windows OSes have a specific set of characters that they disallow regardless of 
the underlying file system, and Linux file systems disallow the null character and 
sometimes / (so, if you just assume that the null character and / are the only 
disallowed characters, you should be fine). I'm not sure what Mac OS X does 
though. In any case, having a function which will convert characters if 
necessary to make the file name valid for the current OS would be useful for 
cross-platform compatability, and it doesn't require a path type.

If we're looking to try and abstract out some of the path stuff a bit better 
without having a separate path type, then having a function like Haskell's 
combine, which concatenates two parts of a path with the appropriate separator 
(so, effectively part1 ~ sep ~ part2) would help (it would clean up code too, 
though you obviously don't _need_ such a function, since we _can_ just 
concatenate with sep). There are probably other, similar functions that we could 
add which would help with abstracting out some of the system-specific, path pain 
without needing a separate path type.

- Jonathan M Davis


More information about the phobos mailing list