summaryrefslogtreecommitdiff
path: root/compiler/hieFile
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2019-01-08 06:31:32 -0800
committerBen Gamari <ben@smart-cactus.org>2019-01-16 14:17:07 -0500
commit9fb2702dec3e9419e1a229f8cd678324e89fdddf (patch)
tree7c65dee12bfeb5037e61b832af16c4ab084cb31a /compiler/hieFile
parent2f65025eeb4a79458af26d759e932d70633a64db (diff)
downloadhaskell-9fb2702dec3e9419e1a229f8cd678324e89fdddf.tar.gz
Create folder if missing for .hie files
Summary: 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: https://phabricator.haskell.org/D5463
Diffstat (limited to 'compiler/hieFile')
-rw-r--r--compiler/hieFile/HieBin.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/hieFile/HieBin.hs b/compiler/hieFile/HieBin.hs
index fa33936f40..2734a9fce9 100644
--- a/compiler/hieFile/HieBin.hs
+++ b/compiler/hieFile/HieBin.hs
@@ -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)