@@ -230,7 +230,9 @@ toStreamWithBufferOf chunkSize h = AS.concat $ toChunksWithBufferOf chunkSize h
230230-- readChildren API.
231231
232232-- 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.
234236--
235237-- /Internal/
236238--
@@ -238,7 +240,8 @@ toStreamWithBufferOf chunkSize h = AS.concat $ toChunksWithBufferOf chunkSize h
238240reader :: MonadIO m => Unfold m FilePath FilePath
239241reader =
240242 -- XXX use proper streaming read of the dir
241− UF.lmapM (liftIO . Dir.getDirectoryContents) UF.fromList
243+ UF.filter (\x -> x /= "." && x /= "..")
244+ $ UF.lmapM (liftIO . Dir.getDirectoryContents) UF.fromList
242245
243246-- XXX We can use a more general mechanism to filter the contents of a
244247-- directory. We can just stat each child and pass on the stat information. We
@@ -252,12 +255,10 @@ reader =
252255--
253256{-# INLINE eitherReader #-}
254257eitherReader :: MonadIO m => Unfold m FilePath (Either FilePath FilePath)
255−eitherReader =
256− UF.mapM2 classify
257− $ UF.filter (\x -> x /= "." && x /= "..")
258− -- XXX use proper streaming read of the dir
259− $ UF.lmapM (liftIO . Dir.getDirectoryContents) UF.fromList
258+eitherReader = UF.mapM2 classify reader
259+
260260 where
261+
261262 classify dir x = do
262263 r <- liftIO $ Dir.doesDirectoryExist (dir ++ "/" ++ x)
263264 return $ if r then Left x else Right x