Re: openFd?
Malcolm Wallace <[email protected]> Tue, 4 Jan 2005 14:28:53 +0000
| Newsgroups | gmane.comp.lang.haskell.nhc.user |
|---|---|
| Organization | Dept of Computer Science, University of York |
| Message-ID | <[email protected]> |
David Roundy <[email protected]> writes: > I'm wondering if there is any equivalent to GHC.Handle.openFd which I can > use with nhc98? It's nice being able to convert a file descriptor into a > Handle... I had a quick look at the documentation for openFd, and it wasn't very informative - no text, just a signature: openFd :: FD -> Maybe FDType -> FilePath -> IOMode -> Bool -> Bool -> IO Handle What are the FPType, FilePath, IOMode, and Bool arguments for? Also, there seem to be plenty of operations that /use/ an FD, but I couldn't find one that /returns/ an FD, so how are they created?. However, my guess is that these library functions are actually a thin skin over some fairly standard C library, in which case you can probably write a little bit of FFI code to interface to the same functionality. nhc98's representation of a Handle as a wrapper over C's FILE* type is "struct FileDesc", defined in src/runtime.h, and an example of some FFI stuff to manipulate a Handle can be seen in src/prelude/IO/OpenFile.hs and src/runtime/Builtin/cOpen.c Regards, Malcolm