summaryrefslogtreecommitdiff
path: root/Utility.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Utility.hs')
-rw-r--r--Utility.hs16
1 files changed, 0 insertions, 16 deletions
diff --git a/Utility.hs b/Utility.hs
index 233825b65..e7b4b510b 100644
--- a/Utility.hs
+++ b/Utility.hs
@@ -6,7 +6,6 @@
-}
module Utility (
- withFileLocked,
hGetContentsStrict,
parentDir,
relPathCwdToDir,
@@ -28,21 +27,6 @@ import System.IO.HVFS
import System.FilePath
import System.Directory
-{- Let's just say that Haskell makes reading/writing a file with
- - file locking excessively difficult. -}
-withFileLocked file mode action = do
- -- TODO: find a way to use bracket here
- handle <- openFile file mode
- lockfd <- handleToFd handle -- closes handle
- waitToSetLock lockfd (lockType mode, AbsoluteSeek, 0, 0)
- handle' <- fdToHandle lockfd
- ret <- action handle'
- hClose handle'
- return ret
- where
- 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