Skip to content

Commit a617a01

Browse files
committed
Fix setting creation date for OSX - revert windows changes & simplify code
Revert the changes for Windows & disable the SettingUpdatesPropertiesOnSymlink test on Windows. Remove unnecessary setting to 0 on the attrList variable. Remove the unnecessary MarshalAs attributes in the AttrList type. Fix for #39132 and issues in #49555.
1 parent b85f323 commit a617a01

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

src/libraries/Common/src/Interop/OSX/Interop.libc.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ internal static partial class libc
1111
[StructLayout(LayoutKind.Sequential)]
1212
internal struct AttrList
1313
{
14-
[MarshalAs(UnmanagedType.U2)] public ushort bitmapCount;
15-
[MarshalAs(UnmanagedType.U2)] public ushort reserved;
16-
[MarshalAs(UnmanagedType.U4)] public uint commonAttr;
17-
[MarshalAs(UnmanagedType.U4)] public uint volAttr;
18-
[MarshalAs(UnmanagedType.U4)] public uint dirAttr;
19-
[MarshalAs(UnmanagedType.U4)] public uint fileAttr;
20-
[MarshalAs(UnmanagedType.U4)] public uint forkAttr;
14+
public ushort bitmapCount;
15+
public ushort reserved;
16+
public uint commonAttr;
17+
public uint volAttr;
18+
public uint dirAttr;
19+
public uint fileAttr;
20+
public uint forkAttr;
2121

2222
public const ushort ATTR_BIT_MAP_COUNT = 5;
2323
public const uint ATTR_CMN_CRTIME = 0x00000200;

src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileOperations.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ internal partial class FileOperations
1919
internal const int FILE_FLAG_BACKUP_SEMANTICS = 0x02000000;
2020
internal const int FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000;
2121
internal const int FILE_FLAG_OVERLAPPED = 0x40000000;
22-
internal const int FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000;
2322

2423
internal const int FILE_LIST_DIRECTORY = 0x0001;
2524
}

src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.OSX.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ internal unsafe void SetCreationTime(string path, DateTimeOffset time)
2222

2323
Interop.libc.AttrList attrList = default;
2424
attrList.bitmapCount = Interop.libc.AttrList.ATTR_BIT_MAP_COUNT;
25-
attrList.reserved = 0;
2625
attrList.commonAttr = Interop.libc.AttrList.ATTR_CMN_CRTIME;
27-
attrList.dirAttr = 0;
28-
attrList.fileAttr = 0;
29-
attrList.forkAttr = 0;
30-
attrList.volAttr = 0;
3126

3227
// Try to set the attribute on the file system entry using setattrlist,
3328
// otherwise fall back to the method used on other unix platforms as the

src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private static SafeFileHandle OpenHandle(string fullPath, bool asDirectory)
158158
Interop.Kernel32.GenericOperations.GENERIC_WRITE,
159159
FileShare.ReadWrite | FileShare.Delete,
160160
FileMode.Open,
161-
(asDirectory ? Interop.Kernel32.FileOperations.FILE_FLAG_BACKUP_SEMANTICS : 0) | Interop.Kernel32.FileOperations.FILE_FLAG_OPEN_REPARSE_POINT);
161+
asDirectory ? Interop.Kernel32.FileOperations.FILE_FLAG_BACKUP_SEMANTICS : 0);
162162

163163
if (handle.IsInvalid)
164164
{

src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void SettingUpdatesPropertiesAfterAnother()
111111
}
112112

113113
[Fact]
114-
[PlatformSpecific(~TestPlatforms.Browser)]
114+
[PlatformSpecific(~(TestPlatforms.Browser | TestPlatforms.Windows))]
115115
public void SettingUpdatesPropertiesOnSymlink()
116116
{
117117
// This test makes sure that the times are set on the symlink itself.

0 commit comments

Comments
 (0)