[commit: packages/directory] master: Refactor pathIsSymbolicLink to use Metadata interface (7794e23)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:36:01 UTC 2017


Repository : ssh://git@git.haskell.org/directory

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7794e2388491059ba2d8cdce606eabbdef83b1fe/directory

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

commit 7794e2388491059ba2d8cdce606eabbdef83b1fe
Author: Phil Ruffwind <rf at rufflewind.com>
Date:   Tue Mar 7 05:38:20 2017 -0500

    Refactor pathIsSymbolicLink to use Metadata interface


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

7794e2388491059ba2d8cdce606eabbdef83b1fe
 System/Directory.hs | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/System/Directory.hs b/System/Directory.hs
index ef92b28..7f314d5 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -1591,13 +1591,12 @@ pathIsSymbolicLink :: FilePath -> IO Bool
 pathIsSymbolicLink path =
   ((`ioeAddLocation` "pathIsSymbolicLink") .
    (`ioeSetFileName` path)) `modifyIOError` do
-#ifdef mingw32_HOST_OS
-    isReparsePoint <$> Win32.getFileAttributes (toExtendedLengthPath path)
-  where
-    isReparsePoint attr = attr .&. win32_fILE_ATTRIBUTE_REPARSE_POINT /= 0
-#else
-    Posix.isSymbolicLink <$> Posix.getSymbolicLinkStatus path
-#endif
+    m <- getSymbolicLinkMetadata path
+    return $
+      case fileTypeFromMetadata m of
+        DirectoryLink -> True
+        SymbolicLink  -> True
+        _             -> False
 
 {-# DEPRECATED isSymbolicLink "Use 'pathIsSymbolicLink' instead" #-}
 isSymbolicLink :: FilePath -> IO Bool



More information about the ghc-commits mailing list