Commit 732e675b authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Use writeFileAtomic everywhere instead of writeFile

parent 855e17c9
......@@ -757,7 +757,7 @@ ppCustomField :: (String,String) -> Doc
ppCustomField (name,val) = text name <> colon <+> showFreeText val
writeHookedBuildInfo :: FilePath -> HookedBuildInfo -> IO ()
writeHookedBuildInfo fpath pbi = writeFile fpath (showHookedBuildInfo pbi)
writeHookedBuildInfo fpath = writeFileAtomic fpath . showHookedBuildInfo
showHookedBuildInfo :: HookedBuildInfo -> String
showHookedBuildInfo (mb_lib_bi, ex_bi) = render $
......
......@@ -198,8 +198,8 @@ maybeGetPersistBuildConfig distPref = do
writePersistBuildConfig :: FilePath -> LocalBuildInfo -> IO ()
writePersistBuildConfig distPref lbi = do
createDirectoryIfMissing False distPref
writeFile (localBuildInfoFile distPref)
(showHeader pkgid ++ '\n' : show lbi)
writeFileAtomic (localBuildInfoFile distPref)
(showHeader pkgid ++ '\n' : show lbi)
where
pkgid = packageId (localPkgDescr lbi)
......
......@@ -71,7 +71,7 @@ import Distribution.Version ( VersionRange(AnyVersion) )
import Distribution.Package
( Package(..) )
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, copyFileVerbose
( createDirectoryIfMissingVerbose, copyFileVerbose, writeFileAtomic
, die, info, intercalate )
import System.FilePath ( (</>) )
import Distribution.Verbosity
......@@ -142,7 +142,7 @@ build pkg_descr lbi verbosity = do
let pkgid = display (packageId pkg_descr)
pfile = buildDir lbi </> "jhc-pkg.conf"
hlfile= buildDir lbi </> (pkgid ++ ".hl")
writeFile pfile $ jhcPkgConf pkg_descr
writeFileAtomic pfile $ jhcPkgConf pkg_descr
rawSystemProgram verbosity jhcProg ["--build-hl="++pfile, "-o", hlfile]
withExe pkg_descr $ \exe -> do
info verbosity ("Building executable "++exeName exe)
......
......@@ -69,7 +69,7 @@ import Distribution.InstalledPackageInfo
emptyInstalledPackageInfo)
import qualified Distribution.InstalledPackageInfo as IPI
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, copyFileVerbose
( createDirectoryIfMissingVerbose, copyFileVerbose, writeFileAtomic
, die, info, notice, setupMessage )
import Distribution.System
( OS(..), buildOS )
......@@ -177,7 +177,7 @@ writeInstalledConfig distPref pkg_descr lbi inplace instConfOverride = do
let instConfDefault | inplace = inplacePkgConfigFile distPref
| otherwise = installedPkgConfigFile distPref
instConf = fromMaybe instConfDefault instConfOverride
writeFile instConf (pkg_config ++ "\n")
writeFileAtomic instConf (pkg_config ++ "\n")
-- |Create a string suitable for writing out to the package config file
showInstalledConfig :: FilePath -> PackageDescription -> LocalBuildInfo -> Bool
......@@ -316,8 +316,8 @@ rawSystemEmit :: ConfiguredProgram -- ^Program to run
rawSystemEmit prog scriptName extraArgs
= case buildOS of
Windows ->
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
_ -> do writeFile scriptName ("#!/bin/sh\n\n"
writeFileAtomic scriptName ("@" ++ path ++ concatMap (' ':) args)
_ -> do writeFileAtomic scriptName ("#!/bin/sh\n\n"
++ (path ++ concatMap (' ':) args)
++ "\n")
p <- getPermissions scriptName
......@@ -334,8 +334,8 @@ rawSystemPipe :: ConfiguredProgram
rawSystemPipe prog scriptName pipeFrom extraArgs
= case buildOS of
Windows ->
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
_ -> do writeFile scriptName ("#!/bin/sh\n\n"
writeFileAtomic scriptName ("@" ++ path ++ concatMap (' ':) args)
_ -> do writeFileAtomic scriptName ("#!/bin/sh\n\n"
++ "echo '" ++ escapeForShell pipeFrom
++ "' | "
++ (path ++ concatMap (' ':) args)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment