aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Resource.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r--compiler/src/Resource.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs
index 83f7438..a8be913 100644
--- a/compiler/src/Resource.hs
+++ b/compiler/src/Resource.hs
@@ -28,13 +28,13 @@ module Resource
28 , ItemProcessor 28 , ItemProcessor
29 , ThumbnailProcessor 29 , ThumbnailProcessor
30 , buildResourceTree 30 , buildResourceTree
31 , flattenResourceTree 31 , cleanupResourceDir
32 , outputDiff
33 ) where 32 ) where
34 33
35 34
36import Data.Function ((&)) 35import Data.Function ((&))
37import Data.List ((\\), subsequences) 36import Data.List ((\\), subsequences, sortBy)
37import Data.Ord (comparing)
38import Data.Maybe (mapMaybe) 38import Data.Maybe (mapMaybe)
39import Files 39import Files
40import Input (InputTree(..), Sidecar) 40import Input (InputTree(..), Sidecar)
@@ -104,3 +104,11 @@ outputDiff resources ref =
104 104
105 fsPaths :: FSNode -> [Path] 105 fsPaths :: FSNode -> [Path]
106 fsPaths = map nodePath . tail . flattenDir 106 fsPaths = map nodePath . tail . flattenDir
107
108cleanupResourceDir :: ResourceTree -> FileName -> IO ()
109cleanupResourceDir resourceTree outputDir =
110 readDirectory outputDir
111 >>= return . outputDiff resourceTree . root
112 >>= return . sortBy (flip $ comparing length) -- nested files before dirs
113 >>= return . map (localPath . (/>) outputDir)
114 >>= mapM_ remove