11{-# LANGUAGE CPP #-}
22{-# LANGUAGE TemplateHaskell #-}
33
4- module Development.IDE.Graph.Internal.Paths (getDataFile ) where
5-
6- import Paths_hls_graph
4+ module Development.IDE.Graph.Internal.Paths (readDataFileHTML ) where
75
86#ifndef FILE_EMBED
9- import Control.Exception (SomeException (SomeException ), catch )
10- import Control.Monad (filterM )
11- import System.Directory (doesFileExist , getCurrentDirectory )
12- import System.Environment (getExecutablePath )
13- import System.FilePath (takeDirectory , (</>) )
14- import System.IO.Unsafe (unsafePerformIO )
7+ import Control.Exception (SomeException (SomeException ), catch )
8+ import Control.Monad (filterM )
9+ import Paths_hls_graph
10+ import System.Directory (doesFileExist , getCurrentDirectory )
11+ import System.Environment (getExecutablePath )
12+ import System.FilePath (takeDirectory , (</>) )
13+ import System.IO.Unsafe (unsafePerformIO )
1514#endif
15+ import qualified Data.ByteString.Lazy as LBS
1616
1717#ifdef FILE_EMBED
18- import qualified Data.ByteString as BS
19- import qualified Data.ByteString as LBS
18+ import qualified Data.ByteString as BS
2019import Data.FileEmbed
2120
22- initDataDirectory :: IO ()
23- initDataDirectory = pure ()
24-
2521htmlDataFiles :: [(FilePath , BS. ByteString )]
2622htmlDataFiles =
2723 [ (" profile.html" , $ (embedFile " html/profile.html" ))
28- , (" progress.html" , $ (embedFile " html/progress.html" ))
2924 , (" shake.js" , $ (embedFile " html/shake.js" ))
3025 ]
3126
@@ -35,18 +30,6 @@ readDataFileHTML file = do
3530 Nothing -> fail $ " Could not find data file " ++ file ++ " in embedded data files!"
3631 Just x -> pure (LBS. fromStrict x)
3732
38- manualDirData :: [(FilePath , BS. ByteString )]
39- manualDirData = $ (embedDir " docs/manual" )
40-
41- hasManualData :: IO Bool
42- hasManualData = pure True
43-
44- copyManualData :: FilePath -> IO ()
45- copyManualData dest = do
46- createDirectoryRecursive dest
47- forM_ manualDirData $ \ (file, bs) -> do
48- BS. writeFile (dest </> file) bs
49-
5033#else
5134-- We want getDataFileName to be relative to the current directory on program startup,
5235-- even if we issue a change directory command. Therefore, first call caches, future ones read.
@@ -68,4 +51,7 @@ getDataFile file = do
6851 [] -> fail $ unlines $ (" Could not find data file " ++ file ++ " , looked in:" ) : map (" " ++ ) poss
6952 x: _ -> pure x
7053
54+ readDataFileHTML :: FilePath -> IO LBS. ByteString
55+ readDataFileHTML file = LBS. readFile =<< getDataFile (" html" </> file)
56+
7157#endif
0 commit comments