summaryrefslogtreecommitdiff
path: root/Utility.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Utility.hs')
-rw-r--r--Utility.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/Utility.hs b/Utility.hs
index 05b06dea7..ab9ce04f3 100644
--- a/Utility.hs
+++ b/Utility.hs
@@ -19,6 +19,10 @@ openLocked file mode = do
lockType ReadMode = ReadLock
lockType _ = WriteLock
+{- A version of hgetContents that is not lazy. Ensures file is
+ - all read before it gets closed. -}
+hGetContentsStrict h = hGetContents h >>= \s -> length s `seq` return s
+
{- Returns the parent directory of a path. Parent of / is "" -}
parentDir :: String -> String
parentDir dir =