module Utils.Drasil.FileIO (createFile) where
import Utils.Drasil.Directory (createDirIfMissing)
import System.FilePath (takeDirectory)
import System.IO (hPutStrLn, hClose, openFile, IOMode(WriteMode))
createFile :: FilePath -> String -> IO ()
createFile :: FilePath -> FilePath -> IO ()
createFile FilePath
path FilePath
contents = do
Bool -> FilePath -> IO ()
createDirIfMissing Bool
True (FilePath -> FilePath
takeDirectory FilePath
path)
Handle
h <- FilePath -> IOMode -> IO Handle
openFile FilePath
path IOMode
WriteMode
Handle -> FilePath -> IO ()
hPutStrLn Handle
h FilePath
contents
Handle -> IO ()
hClose Handle
h