summaryrefslogtreecommitdiff
path: root/src/FileUtils.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-11-14 20:36:26 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-11-14 20:36:26 +0100
commit3f6c94f897231b407e3c976e8d789d420ee5e6b7 (patch)
tree0fee6b28c78c7206c7112a575891b4ab5411ccd4 /src/FileUtils.hs
parent00e5bc0f9874eb9f929e917ba44bbd7b6f2ca4a8 (diff)
Separate module for file-related utilities
Diffstat (limited to 'src/FileUtils.hs')
-rw-r--r--src/FileUtils.hs25
1 files changed, 25 insertions, 0 deletions
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