fix fromOsPath on windows

Same reasons as 9c9baf7c65
This commit is contained in:
Joey Hess 2025-01-29 14:19:25 -04:00
parent 9c9baf7c65
commit 2940cfcd18
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -24,6 +24,8 @@ import "os-string" System.OsString.Internal.Types
import qualified Data.ByteString.Short as S
#if defined(mingw32_HOST_OS)
import GHC.IO (unsafePerformIO)
import System.OsString.Encoding.Internal (cWcharsToChars_UCS2)
import qualified System.OsString.Data.ByteString.Short.Word16 as BS16
#endif
toOsPath :: RawFilePath -> OsPath
@ -38,7 +40,10 @@ toOsPath = OsString . PosixString . S.toShort
fromOsPath :: OsPath -> RawFilePath
#if defined(mingw32_HOST_OS)
fromOsPath = S.fromShort . getWindowsString . getOsString
-- On Windows, OsString contains a ShortByteString that is
-- utf-16 encoded. So have to convert the input from that.
-- This is relatively expensive.
fromOsPath = toRawFilePath . cWcharsToChars_UCS2 . BS16.unpack . getWindowsString
#else
fromOsPath = S.fromShort . getPosixString . getOsString
#endif