[commit: directory] master: Improved Unicode support for canonicalizePath with PEP383 (3a0f2e2)
Max Bolingbroke
batterseapower at hotmail.com
Sun May 15 00:24:17 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/directory
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/3a0f2e2cb94c3e4f346023acc7201409d2876ed8
>---------------------------------------------------------------
commit 3a0f2e2cb94c3e4f346023acc7201409d2876ed8
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date: Sat May 14 22:40:55 2011 +0100
Improved Unicode support for canonicalizePath with PEP383
>---------------------------------------------------------------
System/Directory.hs | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/System/Directory.hs b/System/Directory.hs
index 6c28eef..a352809 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 __GLASGOW_HASKELL__ > 700
+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__ > 700
+ 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