Skip to content
Snippets Groups Projects
Commit c0ec0b36 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Make 'tryCanonicalizePath' work with directory > 1.2.3.0.

parent 05dccd62
No related branches found
No related tags found
No related merge requests found
......@@ -225,13 +225,12 @@ byteStringToFilePath bs | bslen `mod` 4 /= 0 = unexpected
b2 = fromIntegral $ BS.index bs (i + 2)
b3 = fromIntegral $ BS.index bs (i + 3)
-- | Workaround for the inconsistent behaviour of 'canonicalizePath'. It throws
-- an error if the path refers to a non-existent file on *nix, but not on
-- Windows.
-- | Workaround for the inconsistent behaviour of 'canonicalizePath'. Always
-- throws an error if the path refers to a non-existent file.
tryCanonicalizePath :: FilePath -> IO FilePath
tryCanonicalizePath path = do
ret <- canonicalizePath path
#if defined(mingw32_HOST_OS)
#if defined(mingw32_HOST_OS) || MIN_VERSION_directory(1,2,3)
exists <- liftM2 (||) (doesFileExist ret) (doesDirectoryExist ret)
unless exists $
ioError $ mkIOError doesNotExistErrorType "canonicalizePath"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment