X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FDirectory.hs;h=d1cf49518ef9d0e5af8a801bc09aaa83b74cf176;hb=1f9af202c6e595283fe57577eade9b8b4c30355c;hp=c3698a2822357e4e886696b93984fbdbf1902b94;hpb=fe5420ba0484d7a0937ec3a1153bd9b41967a803;p=haskell-directory.git diff --git a/System/Directory.hs b/System/Directory.hs index c3698a2..d1cf495 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -70,6 +70,7 @@ import Prelude hiding ( catch ) import System.Environment ( getEnv ) import System.FilePath +import System.IO import System.IO.Error hiding ( catch, try ) import Control.Monad ( when, unless ) import Control.Exception @@ -92,7 +93,6 @@ import Foreign.C import System.Posix.Types import System.Posix.Internals import System.Time ( ClockTime(..) ) -import System.IO import GHC.IOBase ( IOException(..), IOErrorType(..), ioException ) @@ -101,7 +101,7 @@ A directory contains a series of entries, each of which is a named reference to a file system object (file, directory etc.). Some entries may be hidden, inaccessible, or have some administrative function (e.g. `.' or `..' under POSIX -), but in +), but in this standard all such entries are considered to form part of the directory contents. Entries in sub-directories are not, however, considered to form part of the directory contents. @@ -584,7 +584,9 @@ canonicalizePath fpath = #else do c_realpath pInPath pOutPath #endif - peekCString pOutPath + path <- peekCString pOutPath + return (normalise path) + -- normalise does more stuff, like upper-casing the drive letter #if defined(mingw32_HOST_OS) foreign import stdcall unsafe "GetFullPathNameA" @@ -1025,7 +1027,14 @@ getTemporaryDirectory = do r <- c_GetTempPath (fromIntegral long_path_size) pPath peekCString pPath #else - catch (getEnv "TMPDIR") (\ex -> return "/tmp") + getEnv "TMPDIR" +#if !__NHC__ + `catch` \ex -> case ex of + IOException e | isDoesNotExistError e -> return "/tmp" + _ -> throw ex +#else + `catch` (\ex -> return "/tmp") +#endif #endif #if defined(mingw32_HOST_OS)