X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fhpc%2FHpcUtils.hs;h=ed8be63675fd79932cd1d31e0cb74fe4a81efc7e;hb=1a3efdd6b616f3a101e182f715df5a0e306eb348;hp=b679a37741d4bde91abf4959479bb00f6ed9946b;hpb=a966047ca5c407f336a633d716d3d7b5ed29d231;p=ghc-hetmet.git diff --git a/utils/hpc/HpcUtils.hs b/utils/hpc/HpcUtils.hs index b679a37..ed8be63 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)