Commit fd5a1560 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Revert to ordinary read/writeFile for the config file

parent ad696713
......@@ -41,8 +41,8 @@ import Distribution.Verbosity (Verbosity, normal)
import Hackage.Types (RemoteRepo(..), Repo(..), Username, Password)
import Hackage.ParseUtils
import Hackage.Utils (readTextFileIfExists)
import Distribution.Simple.Utils (notice, warn, writeTextFile)
import Hackage.Utils (readFileIfExists)
import Distribution.Simple.Utils (notice, warn)
--
......@@ -159,7 +159,7 @@ defaultRemoteRepo =
loadConfig :: Verbosity -> FilePath -> IO SavedConfig
loadConfig verbosity configFile =
do defaultConf <- defaultSavedConfig
minp <- readTextFileIfExists configFile
minp <- readFileIfExists configFile
case minp of
Nothing -> do notice verbosity $ "Config file " ++ configFile ++ " not found."
notice verbosity $ "Writing default configuration to " ++ configFile
......@@ -179,7 +179,7 @@ loadConfig verbosity configFile =
writeDefaultConfigFile :: FilePath -> SavedConfig -> IO ()
writeDefaultConfigFile file cfg =
do createDirectoryIfMissing True (takeDirectory file)
writeTextFile file $ showFields configWriteFieldDescrs cfg ++ "\n"
writeFile file $ showFields configWriteFieldDescrs cfg ++ "\n"
showConfig :: SavedConfig -> String
showConfig = showFields configFieldDescrs
......
......@@ -2,16 +2,16 @@ module Hackage.Utils where
import Distribution.ParseUtils (showDependency)
import Distribution.Version (Dependency(..))
import Distribution.Simple.Utils (intercalate, readTextFile)
import Distribution.Simple.Utils (intercalate)
import Control.Monad (guard)
import Control.Exception (Exception, catchJust, ioErrors)
import System.IO.Error (isDoesNotExistError)
readTextFileIfExists :: FilePath -> IO (Maybe String)
readTextFileIfExists path =
readFileIfExists :: FilePath -> IO (Maybe String)
readFileIfExists path =
catchJust fileNotFoundExceptions
(fmap Just (readTextFile path))
(fmap Just (readFile path))
(\_ -> return Nothing)
fileNotFoundExceptions :: Exception -> Maybe IOError
......
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