1
1
{-# LANGUAGE CPP #-}
2
2
{-# LANGUAGE TemplateHaskell #-}
3
3
4
- module Development.IDE.Graph.Internal.Paths (getDataFile ) where
5
-
6
- import Paths_hls_graph
4
+ module Development.IDE.Graph.Internal.Paths (readDataFileHTML ) where
7
5
8
6
#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 )
15
14
#endif
15
+ import qualified Data.ByteString.Lazy as LBS
16
16
17
17
#ifdef FILE_EMBED
18
- import qualified Data.ByteString as BS
19
- import qualified Data.ByteString as LBS
18
+ import qualified Data.ByteString as BS
20
19
import Data.FileEmbed
21
20
22
- initDataDirectory :: IO ()
23
- initDataDirectory = pure ()
24
-
25
21
htmlDataFiles :: [(FilePath , BS. ByteString )]
26
22
htmlDataFiles =
27
23
[ (" profile.html" , $ (embedFile " html/profile.html" ))
28
- , (" progress.html" , $ (embedFile " html/progress.html" ))
29
24
, (" shake.js" , $ (embedFile " html/shake.js" ))
30
25
]
31
26
@@ -35,18 +30,6 @@ readDataFileHTML file = do
35
30
Nothing -> fail $ " Could not find data file " ++ file ++ " in embedded data files!"
36
31
Just x -> pure (LBS. fromStrict x)
37
32
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
-
50
33
#else
51
34
-- We want getDataFileName to be relative to the current directory on program startup,
52
35
-- even if we issue a change directory command. Therefore, first call caches, future ones read.
@@ -68,4 +51,7 @@ getDataFile file = do
68
51
[] -> fail $ unlines $ (" Could not find data file " ++ file ++ " , looked in:" ) : map (" " ++ ) poss
69
52
x: _ -> pure x
70
53
54
+ readDataFileHTML :: FilePath -> IO LBS. ByteString
55
+ readDataFileHTML file = LBS. readFile =<< getDataFile (" html" </> file)
56
+
71
57
#endif
0 commit comments