summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2011-04-13 14:44:18 +0000
committerhallgren <hallgren@chalmers.se>2011-04-13 14:44:18 +0000
commitd066619b8f3b75f635a39988de747fed81db549e (patch)
treec358dad3ce51c31d66b92026040ede5d5a592a71 /src
parent6b8fa745e2656a5069beb2a2aef21fb8f57329d6 (diff)
GF.Infra.UseIO: add functions readBinaryFile & writeBinaryFile
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Infra/UseIO.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/compiler/GF/Infra/UseIO.hs b/src/compiler/GF/Infra/UseIO.hs
index 72875f70d..1240351f6 100644
--- a/src/compiler/GF/Infra/UseIO.hs
+++ b/src/compiler/GF/Infra/UseIO.hs
@@ -186,6 +186,8 @@ putPointE v opts msg act = do
return a
+-- * File IO
+
writeUTF8File :: FilePath -> String -> IO ()
writeUTF8File fpath content = do
h <- openFile fpath WriteMode
@@ -193,6 +195,9 @@ writeUTF8File fpath content = do
hPutStr h content
hClose h
+readBinaryFile path = hGetContents =<< openBinaryFile path ReadMode
+writeBinaryFile path s = withBinaryFile path WriteMode (flip hPutStr s)
+
-- * Functions to limit acesss to arbitrary IO and system commands
restricted io =
either (const io) (const $ fail message) =<< try (getEnv "GF_RESTRICTED")