@@ -12,7 +12,11 @@ import Distribution.Compat.Exception
12
12
import System.FilePath ((</>) )
13
13
import Foreign.C (CInt , eEXIST , getErrno , errnoToIOError )
14
14
15
- import System.IO (Handle , openTempFile , openBinaryTempFile )
15
+ import System.IO (Handle , openTempFile , openBinaryTempFile
16
+ #if defined(__IO_MANAGER_WINIO__)
17
+ , openBinaryTempFileWithDefaultPermissions
18
+ #endif
19
+ )
16
20
import Data.Bits ((.|.) )
17
21
import System.Posix.Internals (c_open , c_close , o_CREAT , o_EXCL , o_RDWR ,
18
22
o_BINARY , o_NONBLOCK , o_NOCTTY ,
@@ -36,10 +40,17 @@ import qualified System.Posix
36
40
-- TODO: This file should probably be removed.
37
41
38
42
-- This is a copy/paste of the openBinaryTempFile definition, but
39
- -- if uses 666 rather than 600 for the permissions. The base library
40
- -- needs to be changed to make this better.
43
+ -- if uses 666 rather than 600 for the permissions. Newer versions
44
+ -- of base have a new function with this behavior which we use on
45
+ -- Windows when the new IO manager is used.
41
46
openNewBinaryFile :: FilePath -> String -> IO (FilePath , Handle )
42
47
openNewBinaryFile dir template = do
48
+ -- This method can't be used under WINIO. Also the current implementation has
49
+ -- thread safety issues depending on which GHC is used. On newer GHC's let's
50
+ -- use the built in one.
51
+ #if defined(__IO_MANAGER_WINIO__)
52
+ openBinaryTempFileWithDefaultPermissions dir template
53
+ #else
43
54
pid <- c_getpid
44
55
findTempName pid
45
56
where
@@ -95,6 +106,8 @@ pathSeparator = '\\'
95
106
#else
96
107
pathSeparator = ' /'
97
108
#endif
109
+ -- /* __IO_MANAGER_WINIO__ */
110
+ #endif
98
111
99
112
-- FIXME: Copied from GHC.Handle
100
113
std_flags , output_flags , rw_flags :: CInt
0 commit comments