aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar David Terei <davidterei@gmail.com>2012-01-09 17:37:14 -0800
committerGravatar David Terei <davidterei@gmail.com>2012-01-09 17:37:14 -0800
commitb2a695f3b7e1698d35b3e2be65198882e50eb252 (patch)
treef4dd6af987f15409da113a58cb8a2311d295f085
parent4b867e2609f8e3caf1ceac751dc8a09aa7f2397a (diff)
Use error not ioError for consistency.
-rw-r--r--System/Posix/Temp.hsc7
-rw-r--r--System/Posix/Temp/ByteString.hsc7
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