@@ -230,7 +230,9 @@ toStreamWithBufferOf chunkSize h = AS.concat $ toChunksWithBufferOf chunkSize h
230-- readChildren API.
230-- readChildren API.
232-- XXX exception handling
232-- XXX exception handling
233−-- | Raw read of a directory
233+
234+-- | Read a directory emitting a stream with names of the children. Filter out
235+-- "." and ".." entries.
235-- /Internal/
237-- /Internal/
@@ -238,7 +240,8 @@ toStreamWithBufferOf chunkSize h = AS.concat $ toChunksWithBufferOf chunkSize h
238reader :: MonadIO m => Unfold m FilePath FilePath
240reader :: MonadIO m => Unfold m FilePath FilePath
240 -- XXX use proper streaming read of the dir
242 -- XXX use proper streaming read of the dir
243+ UF.filter (\x -> x /= "." && x /= "..")
241− UF.lmapM (liftIO . Dir.getDirectoryContents) UF.fromList
244+ $ UF.lmapM (liftIO . Dir.getDirectoryContents) UF.fromList
243-- XXX We can use a more general mechanism to filter the contents of a
246-- XXX We can use a more general mechanism to filter the contents of a
244-- directory. We can just stat each child and pass on the stat information. We
247-- directory. We can just stat each child and pass on the stat information. We
@@ -252,12 +255,10 @@ reader =
253{-# INLINE eitherReader #-}
256{-# INLINE eitherReader #-}
254eitherReader :: MonadIO m => Unfold m FilePath (Either FilePath FilePath)
257eitherReader :: MonadIO m => Unfold m FilePath (Either FilePath FilePath)
256− UF.mapM2 classify
258+eitherReader = UF.mapM2 classify reader
257− $ UF.filter (\x -> x /= "." && x /= "..")
259+
258− -- XXX use proper streaming read of the dir
259− $ UF.lmapM (liftIO . Dir.getDirectoryContents) UF.fromList
261 classify dir x = do
262 classify dir x = do
262 r <- liftIO $ Dir.doesDirectoryExist (dir ++ "/" ++ x)
263 r <- liftIO $ Dir.doesDirectoryExist (dir ++ "/" ++ x)
263 return $ if r then Left x else Right x
264 return $ if r then Left x else Right x