@@ -139,10 +139,14 @@ import qualified Streamly.FileSystem.FDIO as RawIO
140import Streamly.Mem.Array.Types (Array(..))
140import Streamly.Mem.Array.Types (Array(..))
141import Streamly.Streams.Serial (SerialT)
141import Streamly.Streams.Serial (SerialT)
142+import Streamly.Streams.StreamK.Type (IsStream, mkStream)
143+import Streamly.Mem.Array.Types (byteLength, defaultChunkSize)
145+#if !defined(mingw32_HOST_OS)
146+import Streamly.Mem.Array.Types (groupIOVecsOf)
142import Streamly.Streams.StreamD (toStreamD)
147import Streamly.Streams.StreamD (toStreamD)
143import Streamly.Streams.StreamD.Type (fromStreamD)
148import Streamly.Streams.StreamD.Type (fromStreamD)
144−import Streamly.Streams.StreamK.Type (IsStream, mkStream)
149+#endif
145−import Streamly.Mem.Array.Types (byteLength, defaultChunkSize, groupIOVecsOf)
146-- import Streamly.Fold (Fold)
150-- import Streamly.Fold (Fold)
147-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
151-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
@@ -249,6 +253,7 @@ writeArray (Handle fd) arr = withForeignPtr (aStart arr) $ \p -> do
250 aLen = byteLength arr
254 aLen = byteLength arr
256+#if !defined(mingw32_HOST_OS)
252-- | Write an array of 'IOVec' to a file handle.
257-- | Write an array of 'IOVec' to a file handle.
254-- @since 0.7.0
259-- @since 0.7.0
@@ -258,6 +263,7 @@ writeIOVec _ iov | A.length iov == 0 = return ()
258writeIOVec (Handle fd) iov =
263writeIOVec (Handle fd) iov =
259 withForeignPtr (aStart iov) $ \p ->
264 withForeignPtr (aStart iov) $ \p ->
260 RawIO.writevAll fd p (A.length iov)
265 RawIO.writevAll fd p (A.length iov)
262-------------------------------------------------------------------------------
268-------------------------------------------------------------------------------
263-- Stream of Arrays IO
269-- Stream of Arrays IO
@@ -344,14 +350,6 @@ read = A.flattenArrays . readArrays
344writeArrays :: (MonadIO m, Storable a) => Handle -> SerialT m (Array a) -> m ()
350writeArrays :: (MonadIO m, Storable a) => Handle -> SerialT m (Array a) -> m ()
345writeArrays h m = S.mapM_ (liftIO . writeArray h) m
351writeArrays h m = S.mapM_ (liftIO . writeArray h) m
347−-- XXX this is incomplete
348−-- | Write a stream of 'IOVec' arrays to a handle.
351−{-# INLINE writev #-}
352−writev :: MonadIO m => Handle -> SerialT m (Array RawIO.IOVec) -> m ()
353−writev h m = S.mapM_ (liftIO . writeIOVec h) m
355-- | Write a stream of arrays to a handle after coalescing them in chunks of
353-- | Write a stream of arrays to a handle after coalescing them in chunks of
356-- specified size. The chunk size is only a maximum and the actual writes could
354-- specified size. The chunk size is only a maximum and the actual writes could
357-- be smaller than that as we do not split the arrays to fit them to the
355-- be smaller than that as we do not split the arrays to fit them to the
@@ -363,6 +361,15 @@ writeArraysPackedUpto :: (MonadIO m, Storable a)
363 => Int -> Handle -> SerialT m (Array a) -> m ()
361 => Int -> Handle -> SerialT m (Array a) -> m ()
364writeArraysPackedUpto n h xs = writeArrays h $ A.packArraysChunksOf n xs
362writeArraysPackedUpto n h xs = writeArrays h $ A.packArraysChunksOf n xs
364+#if !defined(mingw32_HOST_OS)
365+-- XXX this is incomplete
366+-- | Write a stream of 'IOVec' arrays to a handle.
369+{-# INLINE writev #-}
370+writev :: MonadIO m => Handle -> SerialT m (Array RawIO.IOVec) -> m ()
371+writev h m = S.mapM_ (liftIO . writeIOVec h) m
366-- XXX this is incomplete
373-- XXX this is incomplete
367-- | Write a stream of arrays to a handle after grouping them in 'IOVec' arrays
374-- | Write a stream of arrays to a handle after grouping them in 'IOVec' arrays
368-- of up to a maximum total size. Writes are performed using gather IO via
375-- of up to a maximum total size. Writes are performed using gather IO via
@@ -375,6 +382,7 @@ _writevArraysPackedUpto :: MonadIO m
375 => Int -> Handle -> SerialT m (Array a) -> m ()
382 => Int -> Handle -> SerialT m (Array a) -> m ()
376_writevArraysPackedUpto n h xs =
383_writevArraysPackedUpto n h xs =
377 writev h $ fromStreamD $ groupIOVecsOf n 512 (toStreamD xs)
384 writev h $ fromStreamD $ groupIOVecsOf n 512 (toStreamD xs)
379-- GHC buffer size dEFAULT_FD_BUFFER_SIZE=8192 bytes.
387-- GHC buffer size dEFAULT_FD_BUFFER_SIZE=8192 bytes.