Skip to content

Commit

Permalink
Use backslash as the primary separator on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
harendra-kumar committed Nov 12, 2024
1 parent 003b4b0 commit 8befc44
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/src/Streamly/Internal/FileSystem/Path/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Streamly.Internal.FileSystem.Path.Common
, toChars

-- * Operations
, primarySeparator
, isSeparator
, dropTrailingSeparators
, isSegment
Expand Down Expand Up @@ -201,13 +202,13 @@ wordToChar = unsafeChr . fromIntegral
unsafeIndexChar :: (Unbox a, Integral a) => Int -> Array a -> Char
unsafeIndexChar i a = wordToChar (Array.getIndexUnsafe i a)

-- Portable definition for exporting.

-- | Primary path separator character, @/@ on Posix and @\\@ on Windows.
-- Windows supports @/@ too as a separator. Please use 'isSeparator' for
-- testing if a char is a separator char.
_primarySeparator :: Char
_primarySeparator = posixSeparator
{-# INLINE primarySeparator #-}
primarySeparator :: OS -> Char
primarySeparator Posix = posixSeparator
primarySeparator Windows = windowsSeparator

------------------------------------------------------------------------------
-- Path parsing utilities
Expand Down Expand Up @@ -341,7 +342,7 @@ doAppend os a b = unsafePerformIO $ do
let len = lenA + 1 + lenB
arr <- MutArray.emptyOf len
arr1 <- MutArray.unsafeSplice arr (Array.unsafeThaw a)
arr2 <- MutArray.unsafeSnoc arr1 (charToWord posixSeparator)
arr2 <- MutArray.unsafeSnoc arr1 (charToWord (primarySeparator os))
arr3 <- MutArray.unsafeSplice arr2 (Array.unsafeThaw b)
return (Array.unsafeFreeze arr3)

Expand Down

0 comments on commit 8befc44

Please sign in to comment.