[commit: unix] master: Use error not ioError for consistency. (b2a695f)
David Terei
davidterei at gmail.com
Tue Jan 10 02:37:55 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/unix
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/b2a695f3b7e1698d35b3e2be65198882e50eb252
>---------------------------------------------------------------
commit b2a695f3b7e1698d35b3e2be65198882e50eb252
Author: David Terei <davidterei at gmail.com>
Date: Mon Jan 9 17:37:14 2012 -0800
Use error not ioError for consistency.
>---------------------------------------------------------------
System/Posix/Temp.hsc | 7 ++-----
System/Posix/Temp/ByteString.hsc | 7 ++-----
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/System/Posix/Temp.hsc b/System/Posix/Temp.hsc
index 26ce1c3..e960ea3 100644
--- a/System/Posix/Temp.hsc
+++ b/System/Posix/Temp.hsc
@@ -23,9 +23,6 @@ module System.Posix.Temp (
#include "HsUnix.h"
-#if !HAVE_MKSTEMPS
-import Control.Exception (throwIO)
-#endif
import Foreign.C
import System.IO
#if !HAVE_MKDTEMP
@@ -93,8 +90,8 @@ foreign import ccall unsafe "HsUnix.h __hscore_mkstemps"
-- If you are using as system that doesn't support the mkstemps glibc function
-- (supported in glibc > 2.11) then this function simply throws an error.
mkstemps :: String -> String -> IO (FilePath, Handle)
-mkstemps prefix suffix = do
#if HAVE_MKSTEMPS
+mkstemps prefix suffix = do
let template = prefix ++ "XXXXXX" ++ suffix
lenOfsuf = (fromIntegral $ length suffix) :: CInt
withFilePath template $ \ ptr -> do
@@ -103,7 +100,7 @@ mkstemps prefix suffix = do
h <- fdToHandle (Fd fd)
return (name, h)
#else
- throwIO . userError $ "mkstemps: System does not have a mkstemp C function."
+mkstemps = error "System.Posix.Temp.mkstemps: not available on this platform"
#endif
#if HAVE_MKDTEMP
diff --git a/System/Posix/Temp/ByteString.hsc b/System/Posix/Temp/ByteString.hsc
index fbbf53f..140d36a 100644
--- a/System/Posix/Temp/ByteString.hsc
+++ b/System/Posix/Temp/ByteString.hsc
@@ -23,9 +23,6 @@ module System.Posix.Temp.ByteString (
#include "HsUnix.h"
-#if !HAVE_MKSTEMPS
-import Control.Exception (throwIO)
-#endif
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as BC
@@ -78,8 +75,8 @@ foreign import ccall unsafe "HsUnix.h __hscore_mkstemps"
-- the created file, which contains 6 random characters in between
-- the prefix and suffix.
mkstemps :: ByteString -> ByteString -> IO (RawFilePath, Handle)
-mkstemps prefix suffix = do
#if HAVE_MKSTEMPS
+mkstemps prefix suffix = do
let template = prefix `B.append` (BC.pack "XXXXXX") `B.append` suffix
lenOfsuf = (fromIntegral $ B.length suffix) :: CInt
withFilePath template $ \ ptr -> do
@@ -88,7 +85,7 @@ mkstemps prefix suffix = do
h <- fdToHandle (Fd fd)
return (name, h)
#else
- throwIO . userError $ "mkstemps: System does not have a mkstemp C function."
+mkstemps = error "System.Posix.Temp.mkstemps: not available on this platform"
#endif
#if HAVE_MKDTEMP
More information about the Cvs-libraries
mailing list