Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Cabal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
580bf06b
Commit
580bf06b
authored
May 25, 2020
by
Tamar Christina
Committed by
Oleg Grenrus
Jun 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WINIO: Add support for WINIO to Cabal.
parent
3c7a2220
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
Cabal/Distribution/Compat/Internal/TempFile.hs
Cabal/Distribution/Compat/Internal/TempFile.hs
+28
-14
No files found.
Cabal/Distribution/Compat/Internal/TempFile.hs
View file @
580bf06b
...
...
@@ -10,16 +10,21 @@ module Distribution.Compat.Internal.TempFile (
import
Distribution.Compat.Exception
import
System.FilePath
((
</>
))
import
Foreign.C
(
CInt
,
eEXIST
,
getErrno
,
errnoToIOError
)
import
System.IO
(
Handle
,
openTempFile
,
openBinaryTempFile
)
#
if
defined
(
__IO_MANAGER_WINIO__
)
import
System.IO
(
openBinaryTempFileWithDefaultPermissions
)
#
else
import
Control.Exception
(
onException
)
import
Data.Bits
((
.|.
))
import
System.Posix.Internals
(
c_open
,
c_close
,
o_CREAT
,
o_EXCL
,
o_RDWR
,
o_BINARY
,
o_NONBLOCK
,
o_NOCTTY
,
withFilePath
,
c_getpid
)
import
System.IO.Error
(
isAlreadyExistsError
)
import
Foreign.C
(
CInt
,
eEXIST
,
getErrno
,
errnoToIOError
)
import
GHC.IO.Handle.FD
(
fdToHandle
)
import
Control.Exception
(
onException
)
import
System.Posix.Internals
(
c_open
,
c_close
,
o_EXCL
,
o_BINARY
,
withFilePath
,
o_CREAT
,
o_RDWR
,
o_NONBLOCK
,
o_NOCTTY
)
#
endif
import
System.Posix.Internals
(
c_getpid
)
import
System.IO.Error
(
isAlreadyExistsError
)
#
if
defined
(
mingw32_HOST_OS
)
||
defined
(
ghcjs_HOST_OS
)
import
System.Directory
(
createDirectory
)
...
...
@@ -36,10 +41,17 @@ import qualified System.Posix
-- TODO: This file should probably be removed.
-- This is a copy/paste of the openBinaryTempFile definition, but
-- if uses 666 rather than 600 for the permissions. The base library
-- needs to be changed to make this better.
-- it uses 666 rather than 600 for the permissions. Newer versions
-- of base have a new function with this behavior which we use on
-- Windows when the new IO manager is used.
openNewBinaryFile
::
FilePath
->
String
->
IO
(
FilePath
,
Handle
)
openNewBinaryFile
dir
template
=
do
-- This method can't be used under WINIO. Also the current implementation has
-- thread safety issues depending on which GHC is used. On newer GHC's let's
-- use the built in one.
#
if
defined
(
__IO_MANAGER_WINIO__
)
openBinaryTempFileWithDefaultPermissions
dir
template
#
else
pid
<-
c_getpid
findTempName
pid
where
...
...
@@ -88,6 +100,12 @@ openNewBinaryFile dir template = do
|
last
a
==
pathSeparator
=
a
++
b
|
otherwise
=
a
++
[
pathSeparator
]
++
b
-- FIXME: Copied from GHC.Handle
std_flags
,
output_flags
,
rw_flags
::
CInt
std_flags
=
o_NONBLOCK
.|.
o_NOCTTY
output_flags
=
std_flags
.|.
o_CREAT
rw_flags
=
output_flags
.|.
o_RDWR
-- FIXME: Should use System.FilePath library
pathSeparator
::
Char
#
ifdef
mingw32_HOST_OS
...
...
@@ -95,12 +113,8 @@ pathSeparator = '\\'
#
else
pathSeparator
=
'/'
#
endif
-- FIXME: Copied from GHC.Handle
std_flags
,
output_flags
,
rw_flags
::
CInt
std_flags
=
o_NONBLOCK
.|.
o_NOCTTY
output_flags
=
std_flags
.|.
o_CREAT
rw_flags
=
output_flags
.|.
o_RDWR
-- /* __IO_MANAGER_WINIO__ */
#
endif
createTempDirectory
::
FilePath
->
String
->
IO
FilePath
createTempDirectory
dir
template
=
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment