diff options
author | stolz <unknown> | 2003-05-27 08:59:21 +0000 |
---|---|---|
committer | stolz <unknown> | 2003-05-27 08:59:21 +0000 |
commit | dfbaa4e61b528509e5d3b0f8a26dd390313c2c78 (patch) | |
tree | 86200284efd8fa2c477dc0e4cc5cbc1ae251abf1 /System/Posix/Temp.hsc | |
parent | 7871e1b9e8483190baa3986d7c0b8a998438c5b9 (diff) |
[project @ 2003-05-27 08:59:21 by stolz]
Return file name as well
Suggested by: Martin Norb?ck
Diffstat (limited to 'System/Posix/Temp.hsc')
-rw-r--r-- | System/Posix/Temp.hsc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/System/Posix/Temp.hsc b/System/Posix/Temp.hsc index 4b8b40f..83e4ffe 100644 --- a/System/Posix/Temp.hsc +++ b/System/Posix/Temp.hsc @@ -35,17 +35,18 @@ import Foreign.C -- |'mkstemp' - make a unique filename. -mkstemp :: String -> IO Handle +mkstemp :: String -> IO (String, Handle) mkstemp template = do withCString template $ \ ptr -> do fd <- throwErrnoIfMinus1 "mkstemp" (c_mkstemp ptr) + name <- peekCString ptr #ifdef __GLASGOW_HASKELL__ - fdToHandle fd + h <- fdToHandle fd #else closeFd fd - name <- peekCString ptr - openFile name ReadWriteMode + h <- openFile name ReadWriteMode #endif + return (name, h) foreign import ccall unsafe "mkstemp" c_mkstemp :: CString -> IO Fd |