-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
When a directory is a junction (as opposed to being a regular directory or a symlink) on Windows, as of Preview 7, DirectoryInfo.LinkTarget returns a non-null value, which is wrong. Considering a structure like this:
C:\Test\RealFolder
C:\Test\JunctionToRealFolder -> C:\Test\RealFolder
C:\Test\SymlinkToRealFolder -> C:\Test\RealFolder
DirectoryInfo.LinkTarget for C:\Test\JunctionToRealFolder returns \Test\RealFolder (instead of C:\Test\RealFolder)
DirectoryInfo.LinkTarget for C:\Test\SymlinkToRealFolder returns C:\Test\RealFolder (which is correct)
Strangely, DirectoryInfo.ResolveLinkTarget(returnFinalTarget: true) returns the correct target in all cases (Junction and Symlink).
I suspect the issue comes that you have an incorrect check for a reparse tag kind in your code:
runtime/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs
Line 506 in eeee548
| if ((rdb.ReparseTag & Interop.Kernel32.IOReparseOptions.IO_REPARSE_TAG_SYMLINK) == 0) |
Should instead be:
if (rdb.ReparseTag != Interop.Kernel32.IOReparseOptions.IO_REPARSE_TAG_SYMLINK)Since you say you support symlinks only ATM.