Skip to content

Commit 20698b4

Browse files
authored
UnixFileMode: address remaining feedback. (#71188)
1 parent b122149 commit 20698b4

7 files changed

Lines changed: 5 additions & 11 deletions

File tree

src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs" Link="Common\Interop\Unix\Interop.Libraries.cs" />
5858
<Compile Include="$(CommonPath)Interop\Unix\Interop.Errors.cs" Link="Common\Interop\Unix\System.Native\Interop.Errors.cs" />
5959
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.DeviceFiles.cs" Link="Common\Interop\Unix\System.Native\Interop.DeviceFiles.cs" />
60-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.FChMod.cs" Link="Common\Interop\Unix\System.Native\Interop.FChMod.cs" />
6160
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEUid.cs" Link="Common\Interop\Unix\System.Native\Interop.GetEUid.cs" />
6261
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetPwUid.cs" Link="Common\Interop\Unix\System.Native\Interop.GetPwUid.cs" />
6362
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetGroupName.cs" Link="Common\Interop\Unix\System.Native\Interop.GetGroupName.cs" />

src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
Link="Common\Interop\Unix\Interop.Libraries.cs" />
3232
<Compile Include="$(CommonPath)Interop\Unix\Interop.Errors.cs"
3333
Link="Common\Interop\Unix\System.Native\Interop.Errors.cs" />
34-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.FChMod.cs"
35-
Link="Common\Interop\Unix\System.Native\Interop.FChMod.cs" />
3634
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Stat.cs"
3735
Link="Common\Interop\Unix\System.Native\Interop.Stat.cs" />
3836
<Compile Include="$(CommonPath)System\IO\Archiving.Utils.Unix.cs"

src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchiveEntry.Extract.Unix.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics;
5+
46
namespace System.IO.Compression
57
{
68
public static partial class ZipFileExtensions
79
{
810
static partial void ExtractExternalAttributes(FileStream fs, ZipArchiveEntry entry)
911
{
12+
Debug.Assert(!OperatingSystem.IsWindows());
13+
1014
// Only extract USR, GRP, and OTH file permissions, and ignore
1115
// S_ISUID, S_ISGID, and S_ISVTX bits. This matches unzip's default behavior.
1216
// It is off by default because of this comment:
@@ -22,9 +26,7 @@ static partial void ExtractExternalAttributes(FileStream fs, ZipArchiveEntry ent
2226
// include the permissions, or was made on Windows.
2327
if (permissions != 0)
2428
{
25-
#pragma warning disable CA1416 // Validate platform compatibility
2629
File.SetUnixFileMode(fs.SafeFileHandle, (UnixFileMode)permissions);
27-
#pragma warning restore CA1416
2830
}
2931
}
3032
}

src/libraries/System.IO.Compression.ZipFile/tests/System.IO.Compression.ZipFile.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'Unix' or '$(TargetPlatformIdentifier)' == 'Browser'">
4040
<Compile Include="ZipFile.Unix.cs" />
4141
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs" Link="Interop\Unix\Interop.Libraries.cs" />
42-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.ChMod.cs" Link="Interop\Unix\System.Native\Interop.ChMod.cs" />
4342
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Stat.cs" Link="Interop\Unix\System.Native\Interop.Stat.cs" />
4443
</ItemGroup>
4544
<ItemGroup>

src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static string[] CreateFiles(string folderPath, string[] testPermissions)
100100
string filename = Path.Combine(folderPath, $"{permissions}.txt");
101101
File.WriteAllText(filename, "contents");
102102

103-
Assert.Equal(0, Interop.Sys.ChMod(filename, Convert.ToInt32(permissions, 8)));
103+
File.SetUnixFileMode(filename, (UnixFileMode)Convert.ToInt32(permissions, 8));
104104

105105
// In some environments, the file mode may be modified by the OS.
106106
// See the Rationale section of https://linux.die.net/man/3/chmod.

src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@
9191
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows' and '$(TargetPlatformIdentifier)' != 'Browser' and '$(UseAndroidCrypto)' != 'true' and '$(UseAppleCrypto)' != 'true'">
9292
<Compile Include="X509FilesystemTests.Unix.cs" />
9393
<Compile Include="X509StoreTests.Unix.cs" />
94-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.ChMod.cs"
95-
Link="Common\Interop\Unix\System.Native\Interop.ChMod.cs" />
9694
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
9795
Link="Common\Interop\Unix\Interop.Libraries.cs" />
9896
<Compile Include="$(CommonPath)Interop\Unix\Interop.Errors.cs"

src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,6 @@
593593
<ItemGroup Condition="'$(UseOpenSsl)' == 'true'">
594594
<Compile Include="$(CommonPath)Interop\Unix\Interop.Errors.cs"
595595
Link="Common\Interop\Unix\Interop.Errors.cs" />
596-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.FChMod.cs"
597-
Link="Common\Interop\Unix\System.Native\Interop.FChMod.cs" />
598596
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEUid.cs"
599597
Link="Common\Interop\Unix\System.Native\Interop.GetEUid.cs" />
600598
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetPwUid.cs"

0 commit comments

Comments
 (0)