aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/Temp.hsc
diff options
context:
space:
mode:
authorGravatar stolz <unknown>2003-05-27 08:59:21 +0000
committerGravatar stolz <unknown>2003-05-27 08:59:21 +0000
commitdfbaa4e61b528509e5d3b0f8a26dd390313c2c78 (patch)
tree86200284efd8fa2c477dc0e4cc5cbc1ae251abf1 /System/Posix/Temp.hsc
parent7871e1b9e8483190baa3986d7c0b8a998438c5b9 (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.hsc9
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