
On Thu, Jan 27, 2005 at 11:33:21AM +0000, Keean Schupke wrote:
I guess it's just that I'm more concerned with making possible what is currently impossible (according to the library standards)--that is, using FFI and IO on the same file--rather than just adding utility features that application developers could have written themselves. I suppose we don't need a class for this, all we need is a couple of functions to convert between FilePath and CString.
Except paths are different on different platforms... for example:
/a/b/../c/hello\ there/test
and:
A:\a\b\
notice how the backslash is used to 'escape' a space or meta-character on unix, but is the path separator for windows.
The \ in your first example is not part of the filepath. If this was typed in a shell, the arguments passed to the executable wouldn't contain the backslash. User interfaces certainly do require "interesting" behavior, but the point I was trying to make is that a minimum requirement should be that a program *without* a user interface can work portably. And for me the FFI is sufficiently important that this means that we should be able to mix FFI access to files with the IO (System.IO or whatever) routines. It should be possible to write a program that reads the contents of the current directory via the haskell libraries, and then uses the FFI to access the contents of those files... perhaps to count the number of symbolic links in the current directory. With the current API, this isn't possible, since technically getDirectoryContents returns a unicode string that withCString can't reliably turn into a C string describing the same file as the FilePath describes. It's not a trivial question, since on posix systems the file names are *not* unicode strings, so it's not clear how to implement a getDirectoryContents or the Haskell 98 IO library in general. But whatever is done with FilePaths and unicode, it would be nice to have the ability to mix FFI and System.IO file and directory access routines. At least on most platforms, System.IO must convert FilePaths to CStrings internally anyways, so it's mostly just a question of exposing that conversion. -- David Roundy http://www.darcs.net