@@ -76,8 +76,11 @@ module Streamly.Internal.FileSystem.OS_PATH
7676 , toChars
7777 , toChars_
7878 , toString
79- -- , toCString
80- -- , toW16CString
79+ #ifndef IS_WINDOWS
80+ , asCString
81+ #else
82+ , asCWString
83+ #endif
8184 , toString_
8285 , showRaw
8386
@@ -128,12 +131,15 @@ import Data.Word (Word16)
128131#endif
129132#ifndef IS_WINDOWS
130133import Foreign.C (CString )
134+ #else
135+ import Foreign.C (CWString )
131136#endif
132137import Language.Haskell.TH.Syntax (lift )
133138import Streamly.Internal.Data.Array (Array (.. ))
134139import Streamly.Internal.Data.Stream (Stream )
135140import Streamly.Internal.FileSystem.Path.Common (mkQ , EqCfg (.. ), eqCfg )
136141
142+ import qualified Streamly.Internal.Data.Array as Array
137143import qualified Streamly.Internal.Data.Stream as Stream
138144import qualified Streamly.Internal.FileSystem.Path.Common as Common
139145import qualified Streamly.Internal.Unicode.Stream as Unicode
@@ -382,6 +388,16 @@ instance Show OS_PATH where
382388 show (OS_PATH x) = show x
383389-}
384390
391+ #ifndef IS_WINDOWS
392+ {-# INLINE asCString #-}
393+ asCString :: OS_PATH -> (CString -> IO a ) -> IO a
394+ asCString p = Array. asCStringUnsafe (toChunk p)
395+ #else
396+ {-# INLINE asCWString #-}
397+ asCWString :: OS_PATH -> (CWString -> IO a ) -> IO a
398+ asCWString p = Array. asCWString (toChunk p)
399+ #endif
400+
385401------------------------------------------------------------------------------
386402-- Operations on Path
387403------------------------------------------------------------------------------
0 commit comments