System/Win32/Path: Implement isSymLink.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 10 Nov 2010 15:05:39 +0000 (15:05 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 10 Nov 2010 15:05:39 +0000 (15:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118681 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Win32/Path.inc

index 4760dfd93d6d66a349ae3aaaaad80862af9fe04b..66e50acaea32677a59731848fd2dbde99b516352 100644 (file)
@@ -376,7 +376,15 @@ Path::isDirectory() const {
 
 bool
 Path::isSymLink() const {
-  return false;
+  DWORD attributes = GetFileAttributes(path.c_str());
+
+  if (attributes == INVALID_FILE_ATTRIBUTES)
+    // There's no sane way to report this :(.
+    assert(0 && "GetFileAttributes returned INVALID_FILE_ATTRIBUTES");
+
+  // This isn't exactly what defines a NTFS symlink, but it is only true for
+  // paths that act like a symlink.
+  return attributes & FILE_ATTRIBUTE_REPARSE_POINT;
 }
 
 bool