diff options
Diffstat (limited to 'utils/hpc/HpcUtils.hs')
-rw-r--r-- | utils/hpc/HpcUtils.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/utils/hpc/HpcUtils.hs b/utils/hpc/HpcUtils.hs index b679a37741..ed8be63675 100644 --- a/utils/hpc/HpcUtils.hs +++ b/utils/hpc/HpcUtils.hs @@ -2,6 +2,7 @@ module HpcUtils where import Trace.Hpc.Util import qualified HpcMap as Map +import HpcFlags -- turns \n into ' ' -- | grab's the text behind a HpcPos; @@ -18,3 +19,14 @@ grabHpcPos hsMap span = Nothing -> error $ "bad line number : " ++ show n ) [l1..l2] + +readFileFromPath :: (String -> IO String) -> String -> [String] -> IO String +readFileFromPath err filename@('/':_) _ = readFile filename +readFileFromPath err filename path0 = readTheFile path0 + where + readTheFile [] = err $ "could not find " ++ show filename + ++ " in path " ++ show path0 + readTheFile (dir:dirs) = + catch (do str <- readFile (dir ++ "/" ++ filename) + return str) + (\ _ -> readTheFile dirs) |