summaryrefslogtreecommitdiff
path: root/Utility.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-16 13:38:59 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-16 13:38:59 -0400
commit1260adbd7700ab9e35f61f4ad94b9cc0536f243e (patch)
treec94583f697832cb4f16af6222bd63bd25d80461d /Utility.hs
parent645bc94d3d9e5f08bda74a99e0584768b32da81c (diff)
basic recursion done; skipping git stuff still todo
Diffstat (limited to 'Utility.hs')
-rw-r--r--Utility.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/Utility.hs b/Utility.hs
index e04b44e6f..8005fd17c 100644
--- a/Utility.hs
+++ b/Utility.hs
@@ -7,12 +7,14 @@ module Utility (
parentDir,
relPathCwdToDir,
relPathDirToDir,
+ recurseFiles,
) where
import System.IO
import System.Posix.IO
import Data.String.Utils
import System.Path
+import System.IO.HVFS
import System.FilePath
import System.Directory
@@ -87,3 +89,15 @@ relPathDirToDir from to =
dotdots = take ((length pfrom) - numcommon) $ repeat ".."
numcommon = length $ common
path = join s $ dotdots ++ uncommon
+
+{- Recursively returns all files and symlinks (to anything) in the specified
+ - path. If the path is a file, returns only it. Does not follow symlinks to
+ - directories. -}
+recurseFiles :: FilePath -> IO [FilePath]
+recurseFiles path = do
+ find <- recurseDirStat SystemFS path
+ return $ filesOnly find
+ where
+ filesOnly l = map (\(f,s) -> f) $ filter isFile l
+ isFile (f, HVFSStatEncap s) =
+ vIsRegularFile s || vIsSymbolicLink s