Skip to content

Commit 8befc44

Browse files
Use backslash as the primary separator on windows
1 parent 003b4b0 commit 8befc44

File tree

1 file changed

+6
-5
lines changed
  • core/src/Streamly/Internal/FileSystem/Path

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module Streamly.Internal.FileSystem.Path.Common
2525
, toChars
2626

2727
-- * Operations
28+
, primarySeparator
2829
, isSeparator
2930
, dropTrailingSeparators
3031
, isSegment
@@ -201,13 +202,13 @@ wordToChar = unsafeChr . fromIntegral
201202
unsafeIndexChar :: (Unbox a, Integral a) => Int -> Array a -> Char
202203
unsafeIndexChar i a = wordToChar (Array.getIndexUnsafe i a)
203204

204-
-- Portable definition for exporting.
205-
206205
-- | Primary path separator character, @/@ on Posix and @\\@ on Windows.
207206
-- Windows supports @/@ too as a separator. Please use 'isSeparator' for
208207
-- testing if a char is a separator char.
209-
_primarySeparator :: Char
210-
_primarySeparator = posixSeparator
208+
{-# INLINE primarySeparator #-}
209+
primarySeparator :: OS -> Char
210+
primarySeparator Posix = posixSeparator
211+
primarySeparator Windows = windowsSeparator
211212

212213
------------------------------------------------------------------------------
213214
-- Path parsing utilities
@@ -341,7 +342,7 @@ doAppend os a b = unsafePerformIO $ do
341342
let len = lenA + 1 + lenB
342343
arr <- MutArray.emptyOf len
343344
arr1 <- MutArray.unsafeSplice arr (Array.unsafeThaw a)
344-
arr2 <- MutArray.unsafeSnoc arr1 (charToWord posixSeparator)
345+
arr2 <- MutArray.unsafeSnoc arr1 (charToWord (primarySeparator os))
345346
arr3 <- MutArray.unsafeSplice arr2 (Array.unsafeThaw b)
346347
return (Array.unsafeFreeze arr3)
347348

0 commit comments

Comments
 (0)