mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -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
|
return a
|
||||||
|
|
||||||
|
-- * File IO
|
||||||
|
|
||||||
writeUTF8File :: FilePath -> String -> IO ()
|
writeUTF8File :: FilePath -> String -> IO ()
|
||||||
writeUTF8File fpath content = do
|
writeUTF8File fpath content = do
|
||||||
h <- openFile fpath WriteMode
|
h <- openFile fpath WriteMode
|
||||||
@@ -193,6 +195,9 @@ writeUTF8File fpath content = do
|
|||||||
hPutStr h content
|
hPutStr h content
|
||||||
hClose h
|
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
|
-- * Functions to limit acesss to arbitrary IO and system commands
|
||||||
restricted io =
|
restricted io =
|
||||||
either (const io) (const $ fail message) =<< try (getEnv "GF_RESTRICTED")
|
either (const io) (const $ fail message) =<< try (getEnv "GF_RESTRICTED")
|
||||||
|
|||||||
Reference in New Issue
Block a user