System.Directory (was RE: Proposal for a new I/O library design)

Hi guys, I'm not replying to anything in the message, but...
Is the idea to abstract away from the syntax of pathnames on the platform (eg. directory separator characters)? If so, I'm not sure it's worthwhile. There are lots of differences between pathname conventions: case sensitivity, arbitrary limits on the lengh of filenames, filename extensions, and so on.
Would there be any way to get some of these differences into the System.Directory structure? At least the following would be nice:
pathSeparator :: Char '\\' on Windows, '/' on unices, ':' (I believe) on macs, etc...
directorySeparator :: Char ';' on Windows, ':' on unices, i have no idea on macs
isCaseSensitive :: Bool False on Windows, True on (all?) unices, i have no idea on macs
given just these, i think we'd all be a lot happier. I also don't particularly care whether these are IO operations or just values (so long as they are constant, they might as well be values with unsafePerformIO wrapped around them if necessary). My current approach to figuring this out is to create a directory, change to that directory, get the current path name and try to parse it. This is bad for so many reasons I won't enumerate them here. ...unless this stuff is hiding somewhere else, please let me know (but System.Directory would probably be a good place for it to end up)... - Hal

Hal Daume wrote:
Would there be any way to get some of these differences into the System.Directory structure? At least the following would be nice:
pathSeparator :: Char '\\' on Windows, '/' on unices, ':' (I believe) on macs, etc...
Either '\\' or '/' on Windows. The former is preferred, but the latter also works in most contexts. For Windows, there's also the issue of drive letters and network (UNC) paths.
isCaseSensitive :: Bool False on Windows, True on (all?) unices, i have no idea on macs
It's more accurate to say that most "native" Unix filesystems are
case-sensitive. However, many Unix systems can mount "foreign"
filesystems (FAT, SMB) which aren't case-sensitive.
Another significant distinction is in the handling of non-ASCII
characters. Windows treats filenames as lists of characters; VFAT and
NTFS use Unicode, while FAT filesystems may have an associated
codepage. OTOH, Unix treats filenames as lists of bytes; while
applications may impose an (arbitrary) encoding on filenames, the OS
doesn't.
--
Glynn Clements
participants (2)
-
Glynn Clements
-
Hal Daume