Skip to content

Commit

Permalink
Exclude EUid and EGid for Browser build as they are not supported (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar authored Jul 30, 2020
1 parent 61cbd57 commit fb6cc28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsBrowser)' == 'true'">
<DefineConstants>$(DefineConstants);TARGET_BROWSER</DefineConstants>
</PropertyGroup>
<ItemGroup>
<!-- System.IO.Enumeration.FileSystemEntry is not correctly parsed by CsharpAnalyser so we are skipping this type from autogenerated typeforwards file. -->
<GenFacadesIgnoreMissingType Include="System.IO.Enumeration.FileSystemEntry" />
Expand Down Expand Up @@ -177,8 +180,6 @@
Link="Interop\Unix\Interop.Errors.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.IOErrors.cs"
Link="Interop\Unix\Interop.IOErrors.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEUid.cs"
Link="Common\Interop\Unix\Interop.GetEUid.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.MountPoints.cs"
Link="Common\Interop\Unix\Interop.MountPoints.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Permissions.cs"
Expand All @@ -203,8 +204,6 @@
Link="Common\Interop\Unix\Interop.ChMod.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.CopyFile.cs"
Link="Common\Interop\Unix\Interop.CopyFile.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEGid.cs"
Link="Common\Interop\Unix\Interop.GetEGid.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.LChflags.cs"
Link="Common\Interop\Unix\Interop.LChflags.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Link.cs"
Expand All @@ -228,6 +227,12 @@
<Compile Include="System\IO\FileSystem.Unix.cs" />
<Compile Include="System\IO\FileSystemInfo.Unix.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEUid.cs"
Link="Common\Interop\Unix\Interop.GetEUid.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEGid.cs"
Link="Common\Interop\Unix\Interop.GetEGid.cs" />
</ItemGroup>
<!-- Unix references -->
<ItemGroup Condition="'$(TargetsUnix)' == 'true' or '$(TargetsBrowser)' == 'true'">
<Reference Include="System.Threading" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ internal static void Initialize(
internal bool IsReadOnly(ReadOnlySpan<char> path, bool continueOnError = false)
{
EnsureStatInitialized(path, continueOnError);
#if TARGET_BROWSER
const Interop.Sys.Permissions readBit = Interop.Sys.Permissions.S_IRUSR;
const Interop.Sys.Permissions writeBit = Interop.Sys.Permissions.S_IWUSR;
#else
Interop.Sys.Permissions readBit, writeBit;

if (_fileStatus.Uid == Interop.Sys.GetEUid())
{
// User effectively owns the file
Expand All @@ -58,6 +63,7 @@ internal bool IsReadOnly(ReadOnlySpan<char> path, bool continueOnError = false)
readBit = Interop.Sys.Permissions.S_IROTH;
writeBit = Interop.Sys.Permissions.S_IWOTH;
}
#endif

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

0 comments on commit fb6cc28

Please sign in to comment.