fix toOsPath on windows
After recent changes to use OsPath, test suite fails on windows with: Exception: Uneven number of bytes: 5. This is not a Word16 bytestream. Hopefully this fixes it. The innefficiency of the conversion is unfortunate.
This commit is contained in:
parent
381019ee3f
commit
9c9baf7c65
1 changed files with 7 additions and 4 deletions
|
@ -22,13 +22,16 @@ import Utility.FileSystemEncoding
|
||||||
import System.OsPath
|
import System.OsPath
|
||||||
import "os-string" System.OsString.Internal.Types
|
import "os-string" System.OsString.Internal.Types
|
||||||
import qualified Data.ByteString.Short as S
|
import qualified Data.ByteString.Short as S
|
||||||
|
#if defined(mingw32_HOST_OS)
|
||||||
|
import GHC.IO (unsafePerformIO)
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Unlike System.OsString.fromBytes, on Windows this does not ensure a
|
|
||||||
- valid USC-2LE encoding. The input ByteString must be in a valid encoding
|
|
||||||
- already or uses of the OsPath will fail. -}
|
|
||||||
toOsPath :: RawFilePath -> OsPath
|
toOsPath :: RawFilePath -> OsPath
|
||||||
#if defined(mingw32_HOST_OS)
|
#if defined(mingw32_HOST_OS)
|
||||||
toOsPath = OsString . WindowsString . S.toShort
|
-- On Windows, OsString contains a ShortByteString that is
|
||||||
|
-- utf-16 encoded. So have to convert the input to that.
|
||||||
|
-- This is relatively expensive.
|
||||||
|
toOsPath = unsafePerformIO . encodeFS . fromRawFilePath
|
||||||
#else
|
#else
|
||||||
toOsPath = OsString . PosixString . S.toShort
|
toOsPath = OsString . PosixString . S.toShort
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue