[commit: ghc] wip/T16197: Create folder if missing for .hie files (9fb2702)
git at git.haskell.org
git at git.haskell.org
Thu Jan 17 13:58:36 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/T16197
Link : http://ghc.haskell.org/trac/ghc/changeset/9fb2702dec3e9419e1a229f8cd678324e89fdddf/ghc
>---------------------------------------------------------------
commit 9fb2702dec3e9419e1a229f8cd678324e89fdddf
Author: Alec Theriault <alec.theriault at gmail.com>
Date: Tue Jan 8 06:31:32 2019 -0800
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
>---------------------------------------------------------------
9fb2702dec3e9419e1a229f8cd678324e89fdddf
compiler/hieFile/HieBin.hs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/compiler/hieFile/HieBin.hs b/compiler/hieFile/HieBin.hs
index fa33936..2734a9f 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)
More information about the ghc-commits
mailing list