Skip to content

Commit 02c706e

Browse files
Use appendCtring from the Path module
1 parent 066db13 commit 02c706e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

core/src/Streamly/Internal/FileSystem/Posix/ReadDir.hsc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import Streamly.Internal.Data.Stream (Stream(..), Step(..))
4242
import qualified Streamly.Internal.Data.Array as Array
4343
import qualified Streamly.Internal.Data.MutByteArray as MutByteArray
4444
import qualified Streamly.Internal.Data.Unfold as UF (bracketIO)
45+
import qualified Streamly.Internal.FileSystem.Path.Common as PathC
4546
import qualified Streamly.Internal.FileSystem.PosixPath as Path
4647

4748
#include <dirent.h>
@@ -283,13 +284,11 @@ eitherReader =
283284

284285
{-# INLINE appendCString #-}
285286
appendCString :: PosixPath -> CString -> IO PosixPath
286-
appendCString a b = do
287-
-- XXX We do not need to create an Array from the CString first. We can
288-
-- append it directly if Path can provide a known length stream append
289-
-- operation. Should we ensure that this is pinned in the DT_UNKNOWN case
287+
appendCString x@(PosixPath a) b = do
288+
-- XXX Should we ensure that this is pinned in the DT_UNKNOWN case
290289
-- because we always pass it to a C function which pins it anyway.
291-
b1 <- Array.fromCString (castPtr b)
292-
pure $ Path.append a (Path.unsafeFromChunk b1)
290+
arr <- PathC.appendCString PathC.Posix a b
291+
pure $ PosixPath arr
293292

294293
{-# ANN type ChunkStreamState Fuse #-}
295294
data ChunkStreamState =

0 commit comments

Comments
 (0)