aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Files.hs
diff options
context:
space:
mode:
authorpacien2019-12-26 01:13:42 +0100
committerpacien2019-12-26 01:13:42 +0100
commit2a6467272e18af4864745b9d0267f9fa3ed382dd (patch)
treea81672b9a0d7d9ad0577453c263cbd4d4d6f315c /compiler/src/Files.hs
parent45163fbc93b2bf2f7cb1fc3242ce5d3f51076601 (diff)
downloadldgallery-2a6467272e18af4864745b9d0267f9fa3ed382dd.tar.gz
compiler: implement output dir cleanup
Diffstat (limited to 'compiler/src/Files.hs')
-rw-r--r--compiler/src/Files.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/src/Files.hs b/compiler/src/Files.hs
index 30e4b94..77a8c5b 100644
--- a/compiler/src/Files.hs
+++ b/compiler/src/Files.hs
@@ -23,7 +23,7 @@ module Files
23 ( FileName, LocalPath, WebPath, Path 23 ( FileName, LocalPath, WebPath, Path
24 , (</>), (</), (/>), localPath, webPath 24 , (</>), (</), (/>), localPath, webPath
25 , FSNode(..), AnchoredFSNode(..) 25 , FSNode(..), AnchoredFSNode(..)
26 , nodePath, nodeName, isHidden, flatten, filterDir, readDirectory 26 , nodePath, nodeName, isHidden, flattenDir, filterDir, readDirectory
27 ) where 27 ) where
28 28
29 29
@@ -76,9 +76,10 @@ isHidden :: FSNode -> Bool
76isHidden node = "." `isPrefixOf` filename && length filename > 1 76isHidden node = "." `isPrefixOf` filename && length filename > 1
77 where filename = nodeName node 77 where filename = nodeName node
78 78
79flatten :: FSNode -> [FSNode] 79-- | DFS with intermediate dirs first.
80flatten file@(File _) = [file] 80flattenDir :: FSNode -> [FSNode]
81flatten dir@(Dir _ childs) = dir:(concatMap flatten childs) 81flattenDir file@(File _) = [file]
82flattenDir dir@(Dir _ childs) = dir:(concatMap flattenDir childs)
82 83
83-- | Filters a dir tree. The root is always returned. 84-- | Filters a dir tree. The root is always returned.
84filterDir :: (FSNode -> Bool) -> FSNode -> FSNode 85filterDir :: (FSNode -> Bool) -> FSNode -> FSNode
@@ -87,7 +88,7 @@ filterDir cond (Dir path childs) =
87 filter cond childs & map (filterDir cond) & Dir path 88 filter cond childs & map (filterDir cond) & Dir path
88 89
89readDirectory :: LocalPath -> IO AnchoredFSNode 90readDirectory :: LocalPath -> IO AnchoredFSNode
90readDirectory root = mkNode [""] >>= return . AnchoredFSNode root 91readDirectory root = mkNode [] >>= return . AnchoredFSNode root
91 where 92 where
92 mkNode :: Path -> IO FSNode 93 mkNode :: Path -> IO FSNode
93 mkNode path = 94 mkNode path =