[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 14:50:29 UTC 2010


The following commit has been merged in the master branch:
commit 9bf13e1002c84ed7ae9f66b852927ed9fce56e53
Author: John Goerzen <jgoerzen at complete.org>
Date:   Thu Dec 9 23:55:41 2004 +0100

    Added basic directory recursion
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.7--patch-56)

diff --git a/ChangeLog b/ChangeLog
index c896e2e..f67cc25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
 #
 
+2004-12-09 16:55:41 GMT	John Goerzen <jgoerzen at complete.org>	patch-56
+
+    Summary:
+      Added basic directory recursion
+    Revision:
+      missingh--head--0.7--patch-56
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/Path.hs
+
+
 2004-12-09 16:15:01 GMT	John Goerzen <jgoerzen at complete.org>	patch-55
 
     Summary:
diff --git a/libsrc/MissingH/Path.hs b/libsrc/MissingH/Path.hs
index 6077e62..d5de0dc 100644
--- a/libsrc/MissingH/Path.hs
+++ b/libsrc/MissingH/Path.hs
@@ -26,17 +26,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    Stability  : provisional
    Portability: portable
 
-This module provides various helpful utilities for dealing with path and file
-names.
+This module provides various helpful utilities for dealing with path and
+file names, directories, and related support.
 
 Written by John Goerzen, jgoerzen\@complete.org
 -}
 
-module MissingH.Path(splitExt
+module MissingH.Path(-- * Name processing
+                     splitExt,
+                     -- * Directory Processing
+                     recurseDir, recurseDirStat
                     )
 where
 import Data.List
 import MissingH.List
+import System.Directory
+import System.Posix.Files
 
 {- | Splits a pathname into a tuple representing the root of the name and
 the extension.  The extension is considered to be all characters from the last
@@ -52,3 +57,34 @@ splitExt path =
         if dotindex <= slashindex
            then (path, "")
            else ((take dotindex path), (drop dotindex path))
+
+{- | Obtain a recursive listing of all files\/directories beneath 
+the specified directory.  The traversal is depth-first and the original
+item is always present in the returned list.
+
+If the passed value is not a directory, the return value
+be only that value.
+-}
+recurseDir :: FilePath -> IO [FilePath]
+recurseDir x = recurseDirStat x >>= return . map fst
+
+{- | Like 'recurseDir', but return the stat() (System.Posix.Files.FileStatus)
+information with them.  This is an optimization if you will be statting files
+yourself later.
+-}
+
+recurseDirStat :: FilePath -> IO [(FilePath, FileStatus)]
+recurseDirStat fn =
+    do fs <- getFileStatus fn
+       if isDirectory fs then do
+                              dirc <- getDirectoryContents fn
+                              let contents = map ((++) (fn ++ "/")) $ 
+                                     filter (\x -> x /= "." && x /= "..") dirc
+                              subdirs <- mapM recurseDirStat contents
+                              return $ (concat subdirs) ++ [(fn, fs)]
+          else return [(fn, fs)]
+
+
+                              
+                              
+          
\ No newline at end of file

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list