Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb6cc28

Browse files
authored
Exclude EUid and EGid for Browser build as they are not supported (dotnet#39483)
1 parent 61cbd57 commit fb6cc28

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/libraries/System.IO.FileSystem/src/System.IO.FileSystem.csproj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
8+
<PropertyGroup Condition="'$(TargetsBrowser)' == 'true'">
9+
<DefineConstants>$(DefineConstants);TARGET_BROWSER</DefineConstants>
10+
</PropertyGroup>
811
<ItemGroup>
912
<!-- System.IO.Enumeration.FileSystemEntry is not correctly parsed by CsharpAnalyser so we are skipping this type from autogenerated typeforwards file. -->
1013
<GenFacadesIgnoreMissingType Include="System.IO.Enumeration.FileSystemEntry" />
@@ -177,8 +180,6 @@
177180
Link="Interop\Unix\Interop.Errors.cs" />
178181
<Compile Include="$(CommonPath)Interop\Unix\Interop.IOErrors.cs"
179182
Link="Interop\Unix\Interop.IOErrors.cs" />
180-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEUid.cs"
181-
Link="Common\Interop\Unix\Interop.GetEUid.cs" />
182183
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.MountPoints.cs"
183184
Link="Common\Interop\Unix\Interop.MountPoints.cs" />
184185
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Permissions.cs"
@@ -203,8 +204,6 @@
203204
Link="Common\Interop\Unix\Interop.ChMod.cs" />
204205
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.CopyFile.cs"
205206
Link="Common\Interop\Unix\Interop.CopyFile.cs" />
206-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEGid.cs"
207-
Link="Common\Interop\Unix\Interop.GetEGid.cs" />
208207
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.LChflags.cs"
209208
Link="Common\Interop\Unix\Interop.LChflags.cs" />
210209
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Link.cs"
@@ -228,6 +227,12 @@
228227
<Compile Include="System\IO\FileSystem.Unix.cs" />
229228
<Compile Include="System\IO\FileSystemInfo.Unix.cs" />
230229
</ItemGroup>
230+
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
231+
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEUid.cs"
232+
Link="Common\Interop\Unix\Interop.GetEUid.cs" />
233+
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEGid.cs"
234+
Link="Common\Interop\Unix\Interop.GetEGid.cs" />
235+
</ItemGroup>
231236
<!-- Unix references -->
232237
<ItemGroup Condition="'$(TargetsUnix)' == 'true' or '$(TargetsBrowser)' == 'true'">
233238
<Reference Include="System.Threading" />

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ internal static void Initialize(
3939
internal bool IsReadOnly(ReadOnlySpan<char> path, bool continueOnError = false)
4040
{
4141
EnsureStatInitialized(path, continueOnError);
42+
#if TARGET_BROWSER
43+
const Interop.Sys.Permissions readBit = Interop.Sys.Permissions.S_IRUSR;
44+
const Interop.Sys.Permissions writeBit = Interop.Sys.Permissions.S_IWUSR;
45+
#else
4246
Interop.Sys.Permissions readBit, writeBit;
47+
4348
if (_fileStatus.Uid == Interop.Sys.GetEUid())
4449
{
4550
// User effectively owns the file
@@ -58,6 +63,7 @@ internal bool IsReadOnly(ReadOnlySpan<char> path, bool continueOnError = false)
5863
readBit = Interop.Sys.Permissions.S_IROTH;
5964
writeBit = Interop.Sys.Permissions.S_IWOTH;
6065
}
66+
#endif
6167

6268
return ((_fileStatus.Mode & (int)readBit) != 0 && // has read permission
6369
(_fileStatus.Mode & (int)writeBit) == 0); // but not write permission

0 commit comments

Comments
 (0)