Skip to content

Commit 2494634

Browse files
Abstract some posix/windows stuff for portability
1 parent 81024b4 commit 2494634

File tree

3 files changed

+145
-90
lines changed

3 files changed

+145
-90
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,41 @@
119119
--
120120

121121
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
122+
-- #define IS_WINDOWS
122123
#define OS_PATH WindowsPath
124+
#define FS_WORD Word16
125+
#define FS_CSTRING CWString
123126
#else
124127
#define OS_PATH PosixPath
128+
#define FS_WORD Word8
129+
#define FS_CSTRING CString
125130
#endif
126131

132+
-- #define IS_PORTABLE
133+
-- #include "Streamly/Internal/FileSystem/PosixPath.hs"
134+
127135
module Streamly.Internal.FileSystem.Path
128136
(
129137
Path
138+
, FsWord
139+
, FsCString
140+
, asFsCString
130141
, module Streamly.Internal.FileSystem.OS_PATH
131142
)
132143
where
133144

145+
import Data.Word (FS_WORD)
146+
import Foreign.C.String (FS_CSTRING)
134147
import Streamly.Internal.FileSystem.OS_PATH
135148

136149
type Path = OS_PATH
150+
type FsWord = FS_WORD
151+
type FsCString = FS_CSTRING
152+
153+
{-# INLINE asFsCString #-}
154+
asFsCString :: OS_PATH -> (FsCString -> IO a) -> IO a
155+
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
156+
asFsCString = asCWString
157+
#else
158+
asFsCString = asCString
159+
#endif

0 commit comments

Comments
 (0)