
On Sun, Jan 30, 2005 at 02:17:01PM +0000, Glynn Clements wrote:
Ben Rudiak-Gould wrote:
pathToForeign :: p -> IO (Ptr CChar) pathFromForeign :: Ptr CChar -> IO p
This interface is problematic. Is the pointer returned by pathToForeign a heap pointer which the caller is supposed to free? If so, a Ptr CChar instance would have to copy the pathname every time. And I don't understand exactly what pathFromForeign is supposed to do.
I presume that it's meant to be the fundamental un-marshalling function for the Path class. But it seems Unix-specific; on Windows, filenames wouldn't normally be converted to CChars.
No, it's not Unix-specific, it's portable. If you want to write portable C code, you have to use the standard library, which means that file names are represented as Ptr CChar. Even on Windows, one can program in C, so there does exist a mapping from windows file names to Ptr CChar. It may be that this mapping sometimes fails (i.e. some files may not be accessible via the C standard library), but if this happens one can just throw an exception. -- David Roundy http://www.darcs.net