From bae2b0446ce6105ceadc85fbc4f81ed074ee4199 Mon Sep 17 00:00:00 2001 From: Andrew Gibiansky Date: Fri, 13 Dec 2013 11:15:57 -0800 Subject: [PATCH] Fixing the error that deletes half your filesystem if you use modules --- Main.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Main.hs b/Main.hs index 3c0e168f..0e8d0f2a 100644 --- a/Main.hs +++ b/Main.hs @@ -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