[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 15:01:37 UTC 2010
The following commit has been merged in the master branch:
commit 10fc8d0c681488a2e6a3fec0541a3b385cbae41e
Author: John Goerzen <jgoerzen at complete.org>
Date: Mon Aug 15 19:46:45 2005 +0100
Make recurseDirStat lazy
diff --git a/MissingH/IO/HVFS/Utils.hs b/MissingH/IO/HVFS/Utils.hs
index 4ffbee1..06df95e 100644
--- a/MissingH/IO/HVFS/Utils.hs
+++ b/MissingH/IO/HVFS/Utils.hs
@@ -50,9 +50,11 @@ import MissingH.IO.PlafCompat
import MissingH.Printf
import System.Time
import System.Locale
+import System.IO.Unsafe
{- | Obtain a recursive listing of all files\/directories beneath
-the specified directory. The traversal is depth-first and the original
+the specified directory. The traversal is depth-first (FIXME: is this true?)
+and the original
item is always present in the returned list.
If the passed value is not a directory, the return value
@@ -69,14 +71,15 @@ yourself later.
-}
recurseDirStat :: HVFS a => a -> FilePath -> IO [(FilePath, HVFSStatEncap)]
-recurseDirStat h fn =
+recurseDirStat h fn = unsafeInterleaveIO $
do fs <- vGetSymbolicLinkStatus h fn
- if withStat fs vIsDirectory then do
- dirc <- vGetDirectoryContents h fn
- let contents = map ((++) (fn ++ "/")) $
- filter (\x -> x /= "." && x /= "..") dirc
- subdirs <- mapM (recurseDirStat h) contents
- return $ (concat subdirs) ++ [(fn, fs)]
+ if withStat fs vIsDirectory
+ then do
+ dirc <- vGetDirectoryContents h fn
+ let contents = map ((++) (fn ++ "/")) $
+ filter (\x -> x /= "." && x /= "..") dirc
+ subdirs <- mapM (recurseDirStat h) contents
+ return $ (concat subdirs) ++ [(fn, fs)]
else return [(fn, fs)]
{- | Removes a file or a directory. If a directory, also removes all its
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list