[commit: directory] master: Update for recent mutable locale changes (eb36d7a)
David Terei
davidterei at gmail.com
Fri Nov 18 23:11:45 CET 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/directory
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/eb36d7aeaa58d72399a658bffeae94d1717abe57
>---------------------------------------------------------------
commit eb36d7aeaa58d72399a658bffeae94d1717abe57
Author: David Terei <davidterei at gmail.com>
Date: Fri Nov 18 14:10:25 2011 -0800
Update for recent mutable locale changes
>---------------------------------------------------------------
System/Directory.hs | 41 +++++++++++++++++++++++++++--------------
1 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/System/Directory.hs b/System/Directory.hs
index 6d16dfd..1ef9408 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -714,24 +714,37 @@ copyFile fromFPath toFPath =
-- in either direction: this function can make only a best-effort
-- attempt.
canonicalizePath :: FilePath -> IO FilePath
-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
+canonicalizePath fpath = do
+ path <- Win32.getFullPathName fpath
+ -- normalise does more stuff, like upper-casing the drive letter
+ return (normalise path)
+
+#elif __GLASGOW_HASKELL__ > 700
+canonicalizePath fpath = do
+ enc <- getFileSystemEncoding
+ GHC.withCString enc fpath $ \pInPath ->
+ allocaBytes long_path_size $ \pOutPath -> do
+ throwErrnoPathIfNull "canonicalizePath" fpath $ c_realpath pInPath pOutPath
+ path <- GHC.peekCString enc pOutPath
+ -- normalise does more stuff, like upper-casing the drive letter
+ return (normalise path)
+
#else
- withCString fpath $ \pInPath ->
- allocaBytes long_path_size $ \pOutPath ->
- do throwErrnoPathIfNull "canonicalizePath" fpath $ c_realpath pInPath pOutPath
- path <- peekCString pOutPath
+canonicalizePath fpath =
+ withCString fpath $ \pInPath ->
+ allocaBytes long_path_size $ \pOutPath -> do
+ throwErrnoPathIfNull "canonicalizePath" fpath $ c_realpath pInPath pOutPath
+ path <- peekCString pOutPath
+ -- normalise does more stuff, like upper-casing the drive letter
+ return (normalise path)
#endif
+
+#if __GLASGOW_HASKELL__ < 703
+getFileSystemEncoding :: IO TextEncoding
+getFileSystemEncoding = return fileSystemEncoding
#endif
- return (normalise path)
- -- normalise does more stuff, like upper-casing the drive letter
#if !defined(mingw32_HOST_OS)
foreign import ccall unsafe "realpath"
More information about the Cvs-libraries
mailing list