From: Ian Lynagh Date: Sat, 21 Jul 2007 20:01:54 +0000 (+0000) Subject: Fix doesDirectoryExist; fixes trac #1490 X-Git-Tag: 2007-09-13~6 X-Git-Url: http://git.megacz.com/?p=haskell-directory.git;a=commitdiff_plain;h=e3a4b0478ada7409027379fdf104419a46e219a7 Fix doesDirectoryExist; fixes trac #1490 We used to always strip trailing path separators from the path we were given, but mingw's stat succeeds for C:\ and C:\foo but fails for C: and C:\foo\. Thus we now use a trailing slash if and only if the path we are given is a drive. --- diff --git a/System/Directory.hs b/System/Directory.hs index fd6774c..3301ed3 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -861,14 +861,8 @@ isDirectory stat = do return (s_isdir mode) fileNameEndClean :: String -> String -fileNameEndClean name = - if i > 0 && (ec == '\\' || ec == '/') then - fileNameEndClean (take i name) - else - name - where - i = (length name) - 1 - ec = name !! i +fileNameEndClean name = if isDrive name then addTrailingPathSeparator name + else dropTrailingPathSeparator name foreign import ccall unsafe "__hscore_R_OK" r_OK :: CInt foreign import ccall unsafe "__hscore_W_OK" w_OK :: CInt