Fix doesDirectoryExist; fixes trac #1490
[haskell-directory.git] / System / Directory.hs
index fa48bf2..3301ed3 100644 (file)
@@ -275,7 +275,7 @@ createDirectoryIfMissing parents file = do
     (True,  _,  _) -> return ()
     (_,  True,  _) -> mapM_ (createDirectoryIfMissing False) $ mkParents file
     (_, False,  _) -> createDirectory file
- where mkParents = scanl1 (</>) . splitDirectories . dropDrive . normalise
+ where mkParents = scanl1 (</>) . splitDirectories . normalise
 
 #if __GLASGOW_HASKELL__
 {- | @'removeDirectory' dir@ removes an existing directory /dir/.  The
@@ -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