Browse Source

*

git-svn-id: branches/fixes_3_2@47085 -
marco 4 years ago
parent
commit
b711f33631
1 changed files with 13 additions and 10 deletions
  1. 13 10
      rtl/win/sysutils.pp

+ 13 - 10
rtl/win/sysutils.pp

@@ -472,16 +472,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