on master help sign in
Add toDirs and toFiles
commitfcf54e39240f315c55f8f7442b4d6f3d61edcc26 authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 14 Nov 2019, 05:13 (7 years ago) parentb7c094e
2 files changed+23−5
examples/ListDir.hs+1−1 src/Streamly/Internal/FileSystem/Dir.hs+22−4
examples/ListDir.hs+1−1
@@ -20,7 +20,7 @@ main = do
2020 -- or S.cons dir . S.concatMapWith ahead recursePath
2121 recursePath :: Either String String -> AheadT IO String
2222 recursePath (Left dir) =
23− Dir.toStreamEither dir -- SerialT IO (Either String String)
23+ Dir.toEither dir -- SerialT IO (Either String String)
2424 & S.map (prefixDir dir) -- SerialT IO (Either String String)
2525 & S.consM (return dir)
2626 . S.concatMapWith ahead recursePath -- SerialT IO String
src/Streamly/Internal/FileSystem/Dir.hs+22−4
@@ -26,7 +26,9 @@ module Streamly.Internal.FileSystem.Dir
2626 -- , readWithBufferOf
2727
2828 , toStream
29− , toStreamEither
29+ , toEither
30+ , toFiles
31+ , toDirs
3032 {-
3133 , toStreamWithBufferOf
3234
@@ -277,10 +279,26 @@ toStream = S.unfold read
277279-- entries.
278280--
279281-- /Internal/
280−{-# INLINE toStreamEither #-}
281−toStreamEither :: (IsStream t, MonadIO m)
282+{-# INLINE toEither #-}
283+toEither :: (IsStream t, MonadIO m)
282284 => String -> t m (Either String String)
283−toStreamEither = S.unfold readEither
285+toEither = S.unfold readEither
286+
287+-- | Read files only.
288+--
289+-- /Internal/
290+--
291+{-# INLINE toFiles #-}
292+toFiles :: (IsStream t, MonadIO m) => String -> t m String
293+toFiles = S.unfold readFiles
294+
295+-- | Read directories only.
296+--
297+-- /Internal/
298+--
299+{-# INLINE toDirs #-}
300+toDirs :: (IsStream t, MonadIO m) => String -> t m String
301+toDirs = S.unfold readDirs
284302
285303{-
286304-------------------------------------------------------------------------------