Commit bae2b044 authored by Andrew Gibiansky's avatar Andrew Gibiansky

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

parent 7f97d11d
...@@ -9,6 +9,7 @@ import Control.Concurrent.Chan ...@@ -9,6 +9,7 @@ import Control.Concurrent.Chan
import Data.Aeson import Data.Aeson
import Text.Printf import Text.Printf
import System.Exit (exitSuccess) import System.Exit (exitSuccess)
import System.Directory
import qualified Data.Map as Map import qualified Data.Map as Map
...@@ -57,6 +58,12 @@ main = do ...@@ -57,6 +58,12 @@ main = do
kernel :: String -- ^ Filename of profile JSON file. kernel :: String -- ^ Filename of profile JSON file.
-> IO () -> IO ()
kernel profileSrc = do 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. -- Parse the profile file.
Just profile <- liftM decode . readFile . fpFromText $ pack profileSrc Just profile <- liftM decode . readFile . fpFromText $ pack profileSrc
......
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