diff --git a/System/Directory.hs b/System/Directory.hs index 7cbaa501..695db9cc 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -197,7 +197,8 @@ The operation may fail with: getPermissions :: FilePath -> IO Permissions getPermissions name = do #ifdef mingw32_HOST_OS - withFilePath name $ \s -> do + -- issue #9: Windows doesn't like trailing path separators + withFilePath (dropTrailingPathSeparator name) $ \s -> do -- stat() does a better job of guessing the permissions on Windows -- than access() does. e.g. for execute permission, it looks at the -- filename extension :-) diff --git a/tests/getPermissions001.hs b/tests/getPermissions001.hs index 5e9adf2d..8290d3f8 100644 --- a/tests/getPermissions001.hs +++ b/tests/getPermissions001.hs @@ -1,13 +1,17 @@ import System.Directory main = do +#ifndef mingw32_HOST_OS + let exe = ".exe" +#else + let exe = "" +#endif p <- getPermissions "." print p p <- getPermissions "getPermissions001.hs" print p -#ifndef mingw32_HOST_OS - p <- getPermissions "getPermissions001" -#else - p <- getPermissions "getPermissions001.exe" -#endif + p <- getPermissions ("getPermissions001" ++ exe) print p + + -- issue #9: Windows doesn't like trailing path separators + _ <- getPermissions "../tests/"