aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Files.hs
diff options
context:
space:
mode:
authorpacien2019-12-31 06:58:53 +0100
committerpacien2019-12-31 06:58:53 +0100
commit641ea85d4da795cb2c67d9777cb3db3dfede1d8b (patch)
tree6f6df263e879b64d55038ef400c79b089511fe55 /compiler/src/Files.hs
parent7ef9f09c0f3be1cd5e1f38c9abc845abc9ed3639 (diff)
downloadldgallery-641ea85d4da795cb2c67d9777cb3db3dfede1d8b.tar.gz
compiler: add option to include static web app in the output
GitHub: closes #6
Diffstat (limited to 'compiler/src/Files.hs')
-rw-r--r--compiler/src/Files.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/compiler/src/Files.hs b/compiler/src/Files.hs
index a6649c8..a658ded 100644
--- a/compiler/src/Files.hs
+++ b/compiler/src/Files.hs
@@ -19,6 +19,7 @@
19{-# LANGUAGE 19{-# LANGUAGE
20 DuplicateRecordFields 20 DuplicateRecordFields
21 , DeriveGeneric 21 , DeriveGeneric
22 , NamedFieldPuns
22#-} 23#-}
23 24
24module Files 25module Files
@@ -27,7 +28,8 @@ module Files
27 , fileName, maybeFileName, subPaths, pathLength 28 , fileName, maybeFileName, subPaths, pathLength
28 , localPath, webPath 29 , localPath, webPath
29 , FSNode(..), AnchoredFSNode(..) 30 , FSNode(..), AnchoredFSNode(..)
30 , nodePath, nodeName, isHidden, flattenDir, filterDir, readDirectory 31 , nodePath, nodeName, isHidden, flattenDir, filterDir
32 , readDirectory, copyTo
31 , ensureParentDir, remove, isOutdated 33 , ensureParentDir, remove, isOutdated
32 ) where 34 ) where
33 35
@@ -46,7 +48,8 @@ import System.Directory
46 , getModificationTime 48 , getModificationTime
47 , listDirectory 49 , listDirectory
48 , createDirectoryIfMissing 50 , createDirectoryIfMissing
49 , removePathForcibly ) 51 , removePathForcibly
52 , copyFile )
50 53
51import qualified System.FilePath 54import qualified System.FilePath
52import qualified System.FilePath.Posix 55import qualified System.FilePath.Posix
@@ -146,6 +149,16 @@ readDirectory root = mkNode (Path []) >>= return . AnchoredFSNode root
146 >>= mapM (mkNode . ((</) path)) 149 >>= mapM (mkNode . ((</) path))
147 >>= return . Dir path 150 >>= return . Dir path
148 151
152copyTo :: FilePath -> AnchoredFSNode -> IO ()
153copyTo target AnchoredFSNode{anchor, root} = copyNode root
154 where
155 copyNode :: FSNode -> IO ()
156 copyNode (File path) =
157 copyFile (localPath $ anchor /> path) (localPath $ target /> path)
158
159 copyNode (Dir path items) =
160 createDirectoryIfMissing True (localPath $ target /> path)
161 >> mapM_ copyNode items
149 162
150ensureParentDir :: (FileName -> a -> IO b) -> FileName -> a -> IO b 163ensureParentDir :: (FileName -> a -> IO b) -> FileName -> a -> IO b
151ensureParentDir writer filePath a = 164ensureParentDir writer filePath a =