Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7712,6 +7712,7 @@ public static class InternalSymbolicLinkLinkCodeMethods
// dwDesiredAccess of CreateFile
internal enum FileDesiredAccess : uint
{
GenericZero = 0,
GenericRead = 0x80000000,
GenericWrite = 0x40000000,
GenericExecute = 0x20000000,
Expand Down Expand Up @@ -7917,7 +7918,11 @@ public static string GetTarget(PSObject instance)
if (instance.BaseObject is FileSystemInfo fileSysInfo)
{
#if !UNIX
using (SafeFileHandle handle = OpenReparsePoint(fileSysInfo.FullName, FileDesiredAccess.GenericRead))
// We set accessMode parameter to zero because documentation says:
// If this parameter is zero, the application can query certain metadata
// such as file, directory, or device attributes without accessing
// that file or device, even if GENERIC_READ access would have been denied.
using (SafeFileHandle handle = OpenReparsePoint(fileSysInfo.FullName, FileDesiredAccess.GenericZero))
{
string linkTarget = WinInternalGetTarget(handle);

Expand Down Expand Up @@ -7982,7 +7987,11 @@ private static string WinInternalGetLinkType(string filePath)
throw new PlatformNotSupportedException();
}

using (SafeFileHandle handle = OpenReparsePoint(filePath, FileDesiredAccess.GenericRead))
// We set accessMode parameter to zero because documentation says:
// If this parameter is zero, the application can query certain metadata
// such as file, directory, or device attributes without accessing
// that file or device, even if GENERIC_READ access would have been denied.
using (SafeFileHandle handle = OpenReparsePoint(filePath, FileDesiredAccess.GenericZero))
{
int outBufferSize = Marshal.SizeOf<REPARSE_DATA_BUFFER_SYMBOLICLINK>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ Describe "Get-Item" -Tags "CI" {
${result}.FullName | Should -BeExactly ${item}.FullName
}

It "Should get properties for special reparse points" -skip:$skipNotWindows {
$result = Get-Item -Path $HOME/Cookies -Force
$result.LinkType | Should -BeExactly "Junction"
$result.Target | Should -Not -BeNullOrEmpty
$result.Name | Should -BeExactly "Cookies"
$result.Mode | Should -BeExactly "l--hs"
$result.Exists | Should -BeTrue
}

Context "Test for Include, Exclude, and Filter" {
BeforeAll {
${testBaseDir} = "${TESTDRIVE}/IncludeExclude"
Expand Down