@@ -91,31 +91,43 @@ mergeIterateWith nxt f =
9191 . StreamK. mergeIterateWith f (StreamK. fromStream . nxt)
9292 . StreamK. fromStream
9393
94- streamDir :: Either Path b -> Stream IO (Either Path Path )
95- streamDir = either Dir. readEitherPaths (const Stream. nil)
94+ streamDir
95+ :: (Dir. ReadOptions -> Dir. ReadOptions )
96+ -> Either Path b -> Stream IO (Either Path Path )
97+ streamDir f = either (Dir. readEitherPaths f) (const Stream. nil)
9698
97- unfoldDir :: Unfold IO (Either Path b ) (Either Path Path )
98- unfoldDir = Unfold. either Dir. eitherReaderPaths Unfold. nil
99+ unfoldDir
100+ :: (Dir. ReadOptions -> Dir. ReadOptions )
101+ -> Unfold IO (Either Path b ) (Either Path Path )
102+ unfoldDir f = Unfold. either (Dir. eitherReaderPaths f) Unfold. nil
99103
100- streamDirMaybe :: Either Path b -> Maybe (Stream IO (Either Path Path ))
101- streamDirMaybe = either (Just . Dir. readEitherPaths) (const Nothing )
104+ streamDirMaybe
105+ :: (Dir. ReadOptions -> Dir. ReadOptions )
106+ -> Either Path b -> Maybe (Stream IO (Either Path Path ))
107+ streamDirMaybe f = either (Just . Dir. readEitherPaths f) (const Nothing )
102108
103109#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
104110_streamDirByteChunked
105- :: Either [Path ] b -> Stream IO (Either [Path ] (Array Word8 ))
106- _streamDirByteChunked = either Dir. readEitherByteChunks (const Stream. nil)
111+ :: (Dir. ReadOptions -> Dir. ReadOptions )
112+ -> Either [Path ] b -> Stream IO (Either [Path ] (Array Word8 ))
113+ _streamDirByteChunked f = either (Dir. readEitherByteChunks f) (const Stream. nil)
107114
108115streamDirByteChunkedMaybe
109- :: Either [Path ] b -> Maybe (Stream IO (Either [Path ] (Array Word8 )))
110- streamDirByteChunkedMaybe =
111- either (Just . Dir. readEitherByteChunks) (const Nothing )
116+ :: (Dir. ReadOptions -> Dir. ReadOptions )
117+ -> Either [Path ] b -> Maybe (Stream IO (Either [Path ] (Array Word8 )))
118+ streamDirByteChunkedMaybe f =
119+ either (Just . Dir. readEitherByteChunks f) (const Nothing )
112120#endif
113121
114- streamDirChunkedMaybe :: Either [Path ] b -> Maybe (Stream IO (Either [Path ] [Path ]))
115- streamDirChunkedMaybe = either (Just . Dir. readEitherChunks) (const Nothing )
122+ streamDirChunkedMaybe
123+ :: (Dir. ReadOptions -> Dir. ReadOptions )
124+ -> Either [Path ] b -> Maybe (Stream IO (Either [Path ] [Path ]))
125+ streamDirChunkedMaybe f = either (Just . Dir. readEitherChunks f) (const Nothing )
116126
117- streamDirChunked :: Either [Path ] b -> Stream IO (Either [Path ] [Path ])
118- streamDirChunked = either Dir. readEitherChunks (const Stream. nil)
127+ streamDirChunked
128+ :: (Dir. ReadOptions -> Dir. ReadOptions )
129+ -> Either [Path ] b -> Stream IO (Either [Path ] [Path ])
130+ streamDirChunked f = either (Dir. readEitherChunks f) (const Stream. nil)
119131
120132--------------------------------------------------------------------------------
121133-- Functions
@@ -142,7 +154,7 @@ createDirStucture root d w = do
142154listDirByteChunked :: FilePath -> Stream IO (Array Word8 )
143155listDirByteChunked inp = do
144156 Stream. catRights
145- $ Stream. concatIterateDfs streamDirByteChunkedMaybe
157+ $ Stream. concatIterateDfs ( streamDirByteChunkedMaybe id )
146158 $ Stream. fromPure (Left [fromJust $ Path. fromString inp])
147159#endif
148160
@@ -169,33 +181,121 @@ listDirWith act inp = do
169181 $ act
170182 $ Stream. fromPure (Left (fromJust $ Path. fromString inp))
171183
172- #define DEF_LIST_DIR(x,y); \
173- {-# INLINE x #-}; \
174- x :: [Char ] -> Stream IO Word8 ;\
175- x = listDirWith (y)
176-
177- DEF_LIST_DIR (listDirUnfoldDfs, Stream. unfoldIterateDfs unfoldDir)
178- DEF_LIST_DIR (listDirUnfoldBfs, Stream. unfoldIterateBfs unfoldDir)
179- DEF_LIST_DIR (listDirUnfoldBfsRev, Stream. unfoldIterateBfsRev unfoldDir)
180- DEF_LIST_DIR (listDirConcatDfs, Stream. concatIterateDfs streamDirMaybe)
181- DEF_LIST_DIR (listDirConcatBfs, Stream. concatIterateBfs streamDirMaybe)
182- DEF_LIST_DIR (listDirConcatBfsRev, Stream. concatIterateBfsRev streamDirMaybe)
183- DEF_LIST_DIR (listDirAppend, concatIterateWith streamDir StreamK. append)
184- DEF_LIST_DIR (listDirInterleave, mergeIterateWith streamDir StreamK. interleave)
185- DEF_LIST_DIR (listDirPar, Stream. parConcatIterate id streamDir)
186- DEF_LIST_DIR (listDirParInterleaved, Stream. parConcatIterate (Stream. interleaved True ) streamDir)
187- DEF_LIST_DIR (listDirParOrdered, Stream. parConcatIterate (Stream. ordered True ) streamDir)
188-
189- #define DEF_LIST_DIR_CHUNKED(x,y); \
190- {-# INLINE x #-}; \
191- x :: [Char ] -> Stream IO Word8 ;\
192- x = listDirChunkedWith (y)
193-
194- DEF_LIST_DIR_CHUNKED (listDirChunkDfs, Stream. concatIterateDfs streamDirChunkedMaybe)
195- DEF_LIST_DIR_CHUNKED (listDirChunkBfs, Stream. concatIterateBfs streamDirChunkedMaybe)
196- DEF_LIST_DIR_CHUNKED (listDirChunkBfsRev, Stream. concatIterateBfsRev streamDirChunkedMaybe)
197- DEF_LIST_DIR_CHUNKED (listDirChunkAppend, concatIterateWith streamDirChunked StreamK. append)
198- DEF_LIST_DIR_CHUNKED (listDirChunkInterleave, mergeIterateWith streamDirChunked StreamK. interleave)
199- DEF_LIST_DIR_CHUNKED (listDirChunkPar, Stream. parConcatIterate id streamDirChunked)
200- DEF_LIST_DIR_CHUNKED (listDirChunkParInterleaved, Stream. parConcatIterate (Stream. interleaved True ) streamDirChunked)
201- DEF_LIST_DIR_CHUNKED (listDirChunkParOrdered, Stream. parConcatIterate (Stream. ordered True ) streamDirChunked)
184+ --------------------------------------------------------------------------------
185+ -- Non chunked
186+ --------------------------------------------------------------------------------
187+
188+ {-# INLINE listDirUnfoldDfs #-}
189+ listDirUnfoldDfs
190+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
191+ listDirUnfoldDfs f = listDirWith (Stream. unfoldIterateDfs (unfoldDir f))
192+
193+ {-# INLINE listDirUnfoldBfs #-}
194+ listDirUnfoldBfs
195+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
196+ listDirUnfoldBfs f = listDirWith (Stream. unfoldIterateBfs (unfoldDir f))
197+
198+ {-# INLINE listDirUnfoldBfsRev #-}
199+ listDirUnfoldBfsRev
200+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
201+ listDirUnfoldBfsRev f = listDirWith (Stream. unfoldIterateBfsRev (unfoldDir f))
202+
203+ {-# INLINE listDirConcatDfs #-}
204+ listDirConcatDfs
205+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
206+ listDirConcatDfs f = listDirWith (Stream. concatIterateDfs (streamDirMaybe f))
207+
208+ {-# INLINE listDirConcatBfs #-}
209+ listDirConcatBfs
210+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
211+ listDirConcatBfs f = listDirWith (Stream. concatIterateBfs (streamDirMaybe f))
212+
213+ {-# INLINE listDirConcatBfsRev #-}
214+ listDirConcatBfsRev
215+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
216+ listDirConcatBfsRev f =
217+ listDirWith (Stream. concatIterateBfsRev (streamDirMaybe f))
218+
219+ {-# INLINE listDirAppend #-}
220+ listDirAppend
221+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
222+ listDirAppend f = listDirWith (concatIterateWith (streamDir f) StreamK. append)
223+
224+ {-# INLINE listDirInterleave #-}
225+ listDirInterleave
226+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
227+ listDirInterleave f =
228+ listDirWith (mergeIterateWith (streamDir f) StreamK. interleave)
229+
230+ {-# INLINE listDirPar #-}
231+ listDirPar
232+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
233+ listDirPar f = listDirWith (Stream. parConcatIterate id (streamDir f))
234+
235+ {-# INLINE listDirParInterleaved #-}
236+ listDirParInterleaved
237+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
238+ listDirParInterleaved f =
239+ listDirWith
240+ (Stream. parConcatIterate (Stream. interleaved True ) (streamDir f))
241+
242+ {-# INLINE listDirParOrdered #-}
243+ listDirParOrdered
244+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
245+ listDirParOrdered f =
246+ listDirWith (Stream. parConcatIterate (Stream. ordered True ) (streamDir f))
247+
248+ --------------------------------------------------------------------------------
249+ -- Chunked
250+ --------------------------------------------------------------------------------
251+
252+ {-# INLINE listDirChunkDfs #-}
253+ listDirChunkDfs
254+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
255+ listDirChunkDfs f =
256+ listDirChunkedWith (Stream. concatIterateDfs (streamDirChunkedMaybe f))
257+
258+ {-# INLINE listDirChunkBfs #-}
259+ listDirChunkBfs
260+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
261+ listDirChunkBfs f =
262+ listDirChunkedWith (Stream. concatIterateBfs (streamDirChunkedMaybe f))
263+
264+ {-# INLINE listDirChunkBfsRev #-}
265+ listDirChunkBfsRev
266+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
267+ listDirChunkBfsRev f =
268+ listDirChunkedWith (Stream. concatIterateBfsRev (streamDirChunkedMaybe f))
269+
270+ {-# INLINE listDirChunkAppend #-}
271+ listDirChunkAppend
272+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
273+ listDirChunkAppend f =
274+ listDirChunkedWith (concatIterateWith (streamDirChunked f) StreamK. append)
275+
276+ {-# INLINE listDirChunkInterleave #-}
277+ listDirChunkInterleave
278+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
279+ listDirChunkInterleave f =
280+ listDirChunkedWith
281+ (mergeIterateWith (streamDirChunked f) StreamK. interleave)
282+
283+ {-# INLINE listDirChunkPar #-}
284+ listDirChunkPar
285+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
286+ listDirChunkPar f =
287+ listDirChunkedWith (Stream. parConcatIterate id (streamDirChunked f))
288+
289+ {-# INLINE listDirChunkParInterleaved #-}
290+ listDirChunkParInterleaved
291+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
292+ listDirChunkParInterleaved f =
293+ listDirChunkedWith
294+ (Stream. parConcatIterate (Stream. interleaved True ) (streamDirChunked f))
295+
296+ {-# INLINE listDirChunkParOrdered #-}
297+ listDirChunkParOrdered
298+ :: (Dir. ReadOptions -> Dir. ReadOptions ) -> [Char ] -> Stream IO Word8
299+ listDirChunkParOrdered f =
300+ listDirChunkedWith
301+ (Stream. parConcatIterate (Stream. ordered True ) (streamDirChunked f))
0 commit comments