Browse Source

* handle unknown reparse tags as non-symlinks

git-svn-id: trunk@46761 -
svenbarth 5 years ago
parent
commit
200e20fd71
1 changed files with 13 additions and 10 deletions
  1. 13 10
      rtl/win/sysutils.pp

+ 13 - 10
rtl/win/sysutils.pp

@@ -476,16 +476,19 @@ begin
             end;
           end;
 
-          Handle := FindFirstFileExW(PUnicodeChar(SymLinkRec.TargetName), FindExInfoDefaults , @SymLinkRec.FindData,
-                      FindExSearchNameMatch, Nil, 0);
-          if Handle <> INVALID_HANDLE_VALUE then begin
-            Windows.FindClose(Handle);
-            SymLinkRec.Attr := SymLinkRec.FindData.dwFileAttributes;
-            SymLinkRec.Size := QWord(SymLinkRec.FindData.nFileSizeHigh) shl 32 + QWord(SymLinkRec.FindData.nFileSizeLow);
-          end else if RaiseErrorOnMissing then
-            raise EDirectoryNotFoundException.Create(SysErrorMessage(GetLastOSError))
-          else
-            SymLinkRec.TargetName := '';
+          if SymLinkRec.TargetName <> '' then begin
+            Handle := FindFirstFileExW(PUnicodeChar(SymLinkRec.TargetName), FindExInfoDefaults , @SymLinkRec.FindData,
+                        FindExSearchNameMatch, Nil, 0);
+            if Handle <> INVALID_HANDLE_VALUE then begin
+              Windows.FindClose(Handle);
+              SymLinkRec.Attr := SymLinkRec.FindData.dwFileAttributes;
+              SymLinkRec.Size := QWord(SymLinkRec.FindData.nFileSizeHigh) shl 32 + QWord(SymLinkRec.FindData.nFileSizeLow);
+            end else if RaiseErrorOnMissing then
+              raise EDirectoryNotFoundException.Create(SysErrorMessage(GetLastOSError))
+            else
+              SymLinkRec.TargetName := '';
+          end else
+            SetLastError(ERROR_REPARSE_TAG_INVALID);
         end else
           SetLastError(ERROR_REPARSE_TAG_INVALID);
       finally