on decrease-android-validity help sign in
22 lines 731 B history raw
1module Obelisk.Asset.Symlink
2 ( copyAndSymlink
3 ) where
5import Control.Monad
6import Data.Map (Map)
7import qualified Data.Map as Map
8import System.Directory
9import System.FilePath.Posix
10import System.Posix.Files
12-- | Copy the given hashed files from one location to hashed paths in another
13-- location, and symlink the unhashed paths to the hashed ones
14copyAndSymlink
15 :: Map FilePath FilePath
16 -> FilePath
17 -> FilePath
18 -> IO ()
19copyAndSymlink paths source destination = forM_ (Map.toList paths) $ \(original, hashed) -> do
20 createDirectoryIfMissing True $ destination </> takeDirectory hashed
21 copyFile (source </> original) (destination </> hashed)
22 createSymbolicLink (takeFileName hashed) $ destination </> original