summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--minici.cabal1
-rw-r--r--src/Destination.hs22
-rw-r--r--src/FileUtils.hs25
3 files changed, 28 insertions, 20 deletions
diff --git a/minici.cabal b/minici.cabal
index e82a3b4..c8a9d3a 100644
--- a/minici.cabal
+++ b/minici.cabal
@@ -58,6 +58,7 @@ executable minici
Config
Destination
Eval
+ FileUtils
Job
Job.Types
Output
diff --git a/src/Destination.hs b/src/Destination.hs
index dccac03..4fd8cd8 100644
--- a/src/Destination.hs
+++ b/src/Destination.hs
@@ -10,7 +10,6 @@ module Destination (
copyRecursiveForce,
) where
-import Control.Monad
import Control.Monad.IO.Class
import Data.Text (Text)
@@ -19,6 +18,8 @@ import Data.Text qualified as T
import System.FilePath
import System.Directory
+import FileUtils
+
data Destination
= FilesystemDestination FilePath
@@ -51,22 +52,3 @@ copyToDestination source (FilesystemDestination base) inner = do
liftIO $ do
createDirectoryIfMissing True $ takeDirectory target
copyRecursiveForce source target
-
-
-copyRecursive :: FilePath -> FilePath -> IO ()
-copyRecursive from to = do
- doesDirectoryExist from >>= \case
- False -> do
- copyFile from to
- True -> do
- createDirectory to
- content <- listDirectory from
- forM_ content $ \name -> do
- copyRecursive (from </> name) (to </> name)
-
-copyRecursiveForce :: FilePath -> FilePath -> IO ()
-copyRecursiveForce from to = do
- doesDirectoryExist to >>= \case
- False -> return ()
- True -> removeDirectoryRecursive to
- copyRecursive from to
diff --git a/src/FileUtils.hs b/src/FileUtils.hs
new file mode 100644
index 0000000..d147b7c
--- /dev/null
+++ b/src/FileUtils.hs
@@ -0,0 +1,25 @@
+module FileUtils where
+
+import Control.Monad
+
+import System.FilePath
+import System.Directory
+
+
+copyRecursive :: FilePath -> FilePath -> IO ()
+copyRecursive from to = do
+ doesDirectoryExist from >>= \case
+ False -> do
+ copyFile from to
+ True -> do
+ createDirectory to
+ content <- listDirectory from
+ forM_ content $ \name -> do
+ copyRecursive (from </> name) (to </> name)
+
+copyRecursiveForce :: FilePath -> FilePath -> IO ()
+copyRecursiveForce from to = do
+ doesDirectoryExist to >>= \case
+ False -> return ()
+ True -> removeDirectoryRecursive to
+ copyRecursive from to