[commit: directory] encoding: Fix Unicode error in canonicalizePath (a291e5a)

Max Bolingbroke batterseapower at hotmail.com
Tue Apr 5 10:04:29 CEST 2011


Repository : ssh://darcs.haskell.org//srv/darcs/packages/directory

On branch  : encoding

http://hackage.haskell.org/trac/ghc/changeset/a291e5a38e1f8e6ad0d6be3dac15e5d0271ea59d

>---------------------------------------------------------------

commit a291e5a38e1f8e6ad0d6be3dac15e5d0271ea59d
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date:   Mon Apr 4 22:44:35 2011 +0100

    Fix Unicode error in canonicalizePath

>---------------------------------------------------------------

 System/Directory.hs |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/System/Directory.hs b/System/Directory.hs
index d264583..27d6879 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -112,6 +112,11 @@ import GHC.IO.Exception	( IOException(..), IOErrorType(..), ioException )
 import GHC.IOBase	( IOException(..), IOErrorType(..), ioException )
 #endif
 
+#if MIN_VERSION_base(4,3,2)
+import GHC.IO.Encoding
+import GHC.Foreign as GHC
+#endif
+
 #ifdef mingw32_HOST_OS
 import System.Posix.Types
 import System.Posix.Internals
@@ -710,11 +715,18 @@ canonicalizePath fpath =
 #if defined(mingw32_HOST_OS)
     do path <- Win32.getFullPathName fpath
 #else
+#if __GLASGOW_HASKELL__ && MIN_VERSION_base(4,3,2)
+  GHC.withCString fileSystemEncoding fpath $ \pInPath ->
+  allocaBytes long_path_size $ \pOutPath ->
+    do throwErrnoPathIfNull "canonicalizePath" fpath $ c_realpath pInPath pOutPath
+       path <- GHC.peekCString fileSystemEncoding pOutPath
+#else
   withCString fpath $ \pInPath ->
   allocaBytes long_path_size $ \pOutPath ->
     do throwErrnoPathIfNull "canonicalizePath" fpath $ c_realpath pInPath pOutPath
        path <- peekCString pOutPath
 #endif
+#endif
        return (normalise path)
         -- normalise does more stuff, like upper-casing the drive letter
 





More information about the Cvs-libraries mailing list