Commit 9fb2702d authored by Alec Theriault's avatar Alec Theriault Committed by Ben Gamari

Create folder if missing for .hie files

This matches the existing behaviour for .hi files: if the user requests
the interface file be written in some location, we should create the
parent folder if it doesn't already exist.

Reviewers: bgamari, sjakobi

Reviewed By: sjakobi

Subscribers: sjakobi, rwbarton, carter

Differential Revision:
parent 2f65025e
......@@ -22,7 +22,8 @@ import Data.IORef
import Data.List ( mapAccumR )
import Data.Word ( Word32 )
import Control.Monad ( replicateM )
import System.Directory ( createDirectoryIfMissing )
import System.FilePath ( takeDirectory )
-- | `Name`'s get converted into `HieName`'s before being written into @.hie@
-- files. See 'toHieName' and 'fromHieName' for logic on how to convert between
......@@ -63,7 +64,7 @@ initBinMemSize :: Int
initBinMemSize = 1024*1024
writeHieFile :: Binary a => FilePath -> a -> IO ()
writeHieFile filename hiefile = do
writeHieFile hie_file_path hiefile = do
bh0 <- openBinMem initBinMemSize
-- remember where the dictionary pointer will go
......@@ -115,7 +116,8 @@ writeHieFile filename hiefile = do
putDictionary bh dict_next dict_map
-- and send the result to the file
writeBinMem bh filename
createDirectoryIfMissing True (takeDirectory hie_file_path)
writeBinMem bh hie_file_path
return ()
readHieFile :: Binary a => NameCache -> FilePath -> IO (a, NameCache)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment