
Albert Lee wrote:
and I write that in haskell:
----- import System.Posix import System.IO
main = do dp <- openDirStream "/" df <- readDirStream dp putStrLn df closeDirStream dp
Some code snippets out of harchive, which uses DirStream: bracket (openDirStream path) closeDirStream (getNames []) -- Extract the names in the given DirStream, eliminating "." and "..", -- and sorting the result. getNames :: [String] -> DirStream -> IO [String] getNames names str = do name <- readDirStream str case name of "" -> return (sort names) "." -> getNames names str ".." -> getNames names str _ -> getNames (name:names) str You may not need the names sorted. This also may hold onto some memory on large directories, I haven't looked if something might need to be made more strict. Dave