Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
89b3da21
Commit
89b3da21
authored
Oct 31, 2014
by
Mikhail Glushenkov
Browse files
'writeFileAtomic': use default permissions.
Fixes #2078.
parent
1f41dbf1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/Simple/Utils.hs
View file @
89b3da21
...
@@ -155,7 +155,7 @@ import System.FilePath
...
@@ -155,7 +155,7 @@ import System.FilePath
import
System.Directory
import
System.Directory
(
createDirectory
,
renameFile
,
removeDirectoryRecursive
)
(
createDirectory
,
renameFile
,
removeDirectoryRecursive
)
import
System.IO
import
System.IO
(
Handle
,
openFile
,
openBinaryFile
,
openBinaryTempFile
(
Handle
,
openFile
,
openBinaryFile
,
openBinaryTempFile
WithDefaultPermissions
,
IOMode
(
ReadMode
),
hSetBinaryMode
,
IOMode
(
ReadMode
),
hSetBinaryMode
,
hGetContents
,
stderr
,
stdout
,
hPutStr
,
hFlush
,
hClose
)
,
hGetContents
,
stderr
,
stdout
,
hPutStr
,
hFlush
,
hClose
)
import
System.IO.Error
as
IO.Error
import
System.IO.Error
as
IO.Error
...
@@ -1033,7 +1033,7 @@ writeFileAtomic :: FilePath -> BS.ByteString -> IO ()
...
@@ -1033,7 +1033,7 @@ writeFileAtomic :: FilePath -> BS.ByteString -> IO ()
writeFileAtomic
targetPath
content
=
do
writeFileAtomic
targetPath
content
=
do
let
(
targetDir
,
targetFile
)
=
splitFileName
targetPath
let
(
targetDir
,
targetFile
)
=
splitFileName
targetPath
Exception
.
bracketOnError
Exception
.
bracketOnError
(
openBinaryTempFile
targetDir
$
targetFile
<.>
"tmp"
)
(
openBinaryTempFile
WithDefaultPermissions
targetDir
$
targetFile
<.>
"tmp"
)
(
\
(
tmpPath
,
handle
)
->
hClose
handle
>>
removeFile
tmpPath
)
(
\
(
tmpPath
,
handle
)
->
hClose
handle
>>
removeFile
tmpPath
)
(
\
(
tmpPath
,
handle
)
->
do
(
\
(
tmpPath
,
handle
)
->
do
BS
.
hPut
handle
content
BS
.
hPut
handle
content
...
...
Write
Preview
Supports
Markdown
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