mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-13 06:49:31 -06:00
GF.Infra.UseIO: add functions readBinaryFile & writeBinaryFile
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user