GF.Infra.UseIO: add functions readBinaryFile & writeBinaryFile

This commit is contained in:
hallgren
2011-04-13 14:44:18 +00:00
parent b2ffdd59eb
commit dbea5b1a19

View File

@@ -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")