From 3f6c94f897231b407e3c976e8d789d420ee5e6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Fri, 14 Nov 2025 20:36:26 +0100 Subject: Separate module for file-related utilities --- src/FileUtils.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/FileUtils.hs (limited to 'src/FileUtils.hs') 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 -- cgit v1.2.3