parent
9c9baf7c65
commit
2940cfcd18
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue