Fix encoding issues with realPath
This commit is contained in:
parent
3a52a9ea4b
commit
c7229061d0
13
src/HPath.hs
13
src/HPath.hs
@ -65,6 +65,8 @@ import Data.List
|
|||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Foreign.C.Error
|
import Foreign.C.Error
|
||||||
import Foreign.C.String
|
import Foreign.C.String
|
||||||
|
import GHC.Foreign as GHC
|
||||||
|
import GHC.IO.Encoding (getFileSystemEncoding)
|
||||||
import Foreign.Marshal.Alloc(allocaBytes)
|
import Foreign.Marshal.Alloc(allocaBytes)
|
||||||
import Language.Haskell.TH
|
import Language.Haskell.TH
|
||||||
import HPath.Foreign
|
import HPath.Foreign
|
||||||
@ -307,9 +309,10 @@ foreign import ccall "realpath"
|
|||||||
-- like canonicalizePath, but uses realpath(3)
|
-- like canonicalizePath, but uses realpath(3)
|
||||||
realPath :: String -> IO String
|
realPath :: String -> IO String
|
||||||
realPath inp = do
|
realPath inp = do
|
||||||
allocaBytes pathMax $ \tmp -> do
|
encoding <- getFileSystemEncoding
|
||||||
void $ withCString inp
|
allocaBytes pathMax $ \tmp -> do
|
||||||
$ \cstr -> throwErrnoIfNull "realpath"
|
void $ GHC.withCString encoding inp
|
||||||
$ c_realpath cstr tmp
|
$ \cstr -> throwErrnoIfNull "realpath"
|
||||||
peekCAString tmp
|
$ c_realpath cstr tmp
|
||||||
|
GHC.peekCString encoding tmp
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user