[commit: directory] master: Fix 'createDirectoryIfMissing _ "."' in c:\ on Windows (f85cd29)

Ian Lynagh igloo at earth.li
Sun Feb 3 02:49:11 CET 2013


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

On branch  : master

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

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

commit f85cd29cd468b4ef814aa9f8f3a63108a5a45210
Author: Ian Lynagh <igloo at earth.li>
Date:   Sun Feb 3 01:39:13 2013 +0000

    Fix 'createDirectoryIfMissing _ "."' in c:\ on Windows
    
    We were getting a
        CreateDirectory ".": permission denied (Access is denied.)
    exception, so now we treat isPermissionError like isAlreadyExistsError
    when creating directory (that is, if there is a directory with that
    name then we ignore the exception).

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

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

diff --git a/System/Directory.hs b/System/Directory.hs
index fe9c6f1..097b177 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -392,7 +392,14 @@ createDirectoryIfMissing create_parents path0
           -- the case that the dir did exist but another process deletes the
           -- directory and creates a file in its place before we can check
           -- that the directory did indeed exist.
-          | isAlreadyExistsError e -> (do
+          -- We also follow this path when we get a permissions error, as
+          -- trying to create "." when in the root directory on Windows
+          -- fails with
+          --     CreateDirectory ".": permission denied (Access is denied.)
+          -- This caused GHCi to crash when loading a module in the root
+          -- directory.
+          | isAlreadyExistsError e
+         || isPermissionError e -> (do
 #ifdef mingw32_HOST_OS
               withFileStatus "createDirectoryIfMissing" dir $ \st -> do
                  isDir <- isDirectory st





More information about the ghc-commits mailing list