diff options
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r-- | compiler/src/Resource.hs | 14 |
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 | ||
36 | import Data.Function ((&)) | 35 | import Data.Function ((&)) |
37 | import Data.List ((\\), subsequences) | 36 | import Data.List ((\\), subsequences, sortBy) |
37 | import Data.Ord (comparing) | ||
38 | import Data.Maybe (mapMaybe) | 38 | import Data.Maybe (mapMaybe) |
39 | import Files | 39 | import Files |
40 | import Input (InputTree(..), Sidecar) | 40 | import 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 | |||
108 | cleanupResourceDir :: ResourceTree -> FileName -> IO () | ||
109 | cleanupResourceDir 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 | ||