Skip to content

Commit 0a98d83

Browse files
Replace Array API calls with Path API in Posix Syscalls
1 parent 8a5a380 commit 0a98d83

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

core/src/Streamly/Internal/FileSystem/PathIO.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ getCurrentDirectory = modifyError $ do
5252

5353
-- | Set the current working directory.
5454
setCurrentDirectory :: Path -> IO ()
55-
setCurrentDirectory p = modifyError $
56-
Syscall.setCwd (toArray p)
55+
setCurrentDirectory p = modifyError $ Syscall.setCwd p
5756

5857
where
5958

core/src/Streamly/Internal/Syscall/Posix.hsc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ import Foreign.Storable (peekByteOff)
3535
import GHC.Base (Addr##)
3636
import GHC.Ptr (Ptr(..))
3737
import Streamly.Internal.Data.Array.Type (Array(..))
38-
import qualified Streamly.Internal.Data.Array as Array
3938
import qualified Streamly.Internal.Data.MutByteArray as MutByteArray
4039
import Streamly.Internal.Data.MutByteArray.Type
4140
(MutByteArray, PinnedState(..), unsafeAsPtr)
4241
import Streamly.Internal.Syscall.Common (retry)
42+
import Streamly.Internal.FileSystem.PosixPath (PosixPath)
43+
import qualified Streamly.Internal.FileSystem.PosixPath as Path
4344
import System.Posix.Types (CMode)
4445

4546
#include <sys/stat.h>
@@ -81,9 +82,9 @@ getCwd = do
8182
foreign import ccall unsafe "chdir"
8283
c_chdir :: CString -> IO CInt
8384

84-
setCwd :: Array Word8 -> IO ()
85-
setCwd arr =
86-
Array.asCStringUnsafe arr $
85+
setCwd :: PosixPath -> IO ()
86+
setCwd path =
87+
Path.asCString path $
8788
throwErrnoIfMinus1_ "setCwd" . c_chdir
8889

8990
--------------------------------------------------------------------------------

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ openDirStreamCString s = do
155155
-- {-# INLINE openDirStream #-}
156156
openDirStream :: PosixPath -> IO DirStream
157157
openDirStream p =
158-
Array.asCStringUnsafe (Path.toArray p) $ \s -> do
158+
Path.asCString p $ \s -> do
159159
-- openDirStreamCString s
160160
dirp <- throwErrnoPathIfNullRetry "openDirStream" p $ c_opendir s
161161
return (DirStream dirp)
@@ -214,7 +214,7 @@ statEntryType conf parent dname = do
214214
-- XXX We can create a pinned array right here since the next call pins
215215
-- it anyway.
216216
path <- Path.appendCString parent dname
217-
Array.asCStringUnsafe (Path.toArray path) $ \cStr -> do
217+
Path.asCString path $ \cStr -> do
218218
res <- stat (_followSymlinks conf) cStr
219219
case res of
220220
Right mode -> pure $

0 commit comments

Comments
 (0)