Fixing the error that deletes half your filesystem if you use modules

This commit is contained in:
Andrew Gibiansky 2013-12-13 11:15:57 -08:00
parent 7f97d11de9
commit bae2b0446c

View File

@ -9,6 +9,7 @@ import Control.Concurrent.Chan
import Data.Aeson
import Text.Printf
import System.Exit (exitSuccess)
import System.Directory
import qualified Data.Map as Map
@ -57,6 +58,12 @@ main = do
kernel :: String -- ^ Filename of profile JSON file.
-> IO ()
kernel profileSrc = do
-- Switch to a temporary directory so that any files we create aren't
-- visible. On Unix, this is usually /tmp. If there is no temporary
-- directory available, just stay in the current one and ignore the
-- raised exception.
try (getTemporaryDirectory >>= setCurrentDirectory) :: IO (Either SomeException ())
-- Parse the profile file.
Just profile <- liftM decode . readFile . fpFromText $ pack profileSrc