fix windows build and clarify comment
This commit is contained in:
parent
76bff3e8d1
commit
4e999af7ac
1 changed files with 10 additions and 7 deletions
|
@ -53,36 +53,39 @@ instance OsPathConv FilePath where
|
||||||
|
|
||||||
#ifdef WITH_OSPATH
|
#ifdef WITH_OSPATH
|
||||||
instance OsPathConv RawFilePath where
|
instance OsPathConv RawFilePath where
|
||||||
toOsPath = bytesToOsPath . S.toShort
|
|
||||||
#if defined(mingw32_HOST_OS)
|
#if defined(mingw32_HOST_OS)
|
||||||
|
toOsPath = bytesToOsPath
|
||||||
fromOsPath = bytesFromOsPath
|
fromOsPath = bytesFromOsPath
|
||||||
#else
|
#else
|
||||||
|
toOsPath = bytesToOsPath . S.toShort
|
||||||
fromOsPath = S.fromShort . bytesFromOsPath
|
fromOsPath = S.fromShort . bytesFromOsPath
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
instance OsPathConv ShortByteString where
|
instance OsPathConv ShortByteString where
|
||||||
toOsPath = bytesToOsPath
|
|
||||||
#if defined(mingw32_HOST_OS)
|
#if defined(mingw32_HOST_OS)
|
||||||
|
toOsPath = bytesToOsPath . S.fromShort
|
||||||
fromOsPath = S.toShort . bytesFromOsPath
|
fromOsPath = S.toShort . bytesFromOsPath
|
||||||
#else
|
#else
|
||||||
|
toOsPath = bytesToOsPath
|
||||||
fromOsPath = bytesFromOsPath
|
fromOsPath = bytesFromOsPath
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bytesToOsPath :: ShortByteString -> OsPath
|
|
||||||
#if defined(mingw32_HOST_OS)
|
#if defined(mingw32_HOST_OS)
|
||||||
-- On Windows, OsString contains a ShortByteString that is
|
-- On Windows, OsString contains a ShortByteString that is
|
||||||
-- utf-16 encoded. So have to convert the input to that.
|
-- utf-16 encoded. But the input RawFilePath is assumed to
|
||||||
-- This is relatively expensive.
|
-- be utf-8. So this is a relatively expensive conversion.
|
||||||
|
bytesToOsPath :: RawFilePath -> OsPath
|
||||||
bytesToOsPath = unsafePerformIO . encodeFS . fromRawFilePath
|
bytesToOsPath = unsafePerformIO . encodeFS . fromRawFilePath
|
||||||
#else
|
#else
|
||||||
|
bytesToOsPath :: ShortByteString -> OsPath
|
||||||
bytesToOsPath = OsString . PosixString
|
bytesToOsPath = OsString . PosixString
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(mingw32_HOST_OS)
|
#if defined(mingw32_HOST_OS)
|
||||||
bytesFromOsPath :: OsPath -> RawFilePath
|
bytesFromOsPath :: OsPath -> RawFilePath
|
||||||
-- On Windows, OsString contains a ShortByteString that is
|
-- On Windows, OsString contains a ShortByteString that is
|
||||||
-- utf-16 encoded. So have to convert the input from that.
|
-- utf-16 encoded, but RawFilePath is utf-8.
|
||||||
-- This is relatively expensive.
|
-- So this is relatively expensive conversion.
|
||||||
bytesFromOsPath = toRawFilePath . cWcharsToChars_UCS2 . BS16.unpack . getWindowsString
|
bytesFromOsPath = toRawFilePath . cWcharsToChars_UCS2 . BS16.unpack . getWindowsString
|
||||||
#else
|
#else
|
||||||
bytesFromOsPath :: OsPath -> ShortByteString
|
bytesFromOsPath :: OsPath -> ShortByteString
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue