Skip to content

Commit

Permalink
[browser][file system] GetLogicalDrives implementation (dotnet#39763)
Browse files Browse the repository at this point in the history
- Directory.GetLogicalDrives threw PNSE.  Follows existing code paths.
- Add common DriveInfoInternal.Browser that is common code path for other implementations
   - Environment.GetLogicalDrives
   - DriveInfo.Drives

Fix for FileSystemTest https://github.com/dotnet/runtime/blob/master/src/libraries/System.IO.FileSystem/tests/Directory/GetLogicalDrives.cs
  • Loading branch information
kjpou1 authored and Jacksondr5 committed Aug 10, 2020
1 parent 63e2e16 commit a28a47a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Unlink.cs"
Link="Common\Interop\Unix\Interop.Unlink.cs" />
<Compile Include="$(CoreLibSharedDir)System\IO\DriveInfoInternal.Unix.cs"
Link="Common\System\IO\DriveInfoInternal.Unix.cs" />
Link="Common\System\IO\DriveInfoInternal.Unix.cs" Condition="'$(TargetsBrowser)' != 'true'" />
<Compile Include="$(CoreLibSharedDir)System\IO\DriveInfoInternal.Browser.cs"
Link="Common\System\IO\DriveInfoInternal.Browser.cs" Condition="'$(TargetsBrowser)' == 'true'" />
<Compile Include="$(CoreLibSharedDir)System\IO\PathInternal.Unix.cs"
Link="System\IO\PathInternal.Unix.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,8 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\GlobalizationMode.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Guid.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\DriveInfoInternal.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\DriveInfoInternal.Unix.cs" Condition="'$(TargetsBrowser)' != 'true'"/>
<Compile Include="$(MSBuildThisFileDirectory)System\IO\DriveInfoInternal.Browser.cs" Condition="'$(TargetsBrowser)' == 'true'"/>
<Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.Lock.OSX.cs" Condition="'$(IsOSXLike)' == 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.Lock.Unix.cs" Condition="'$(IsOSXLike)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.Unix.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.IO;

namespace System
{
public static partial class Environment
{
// Emscripten VFS mounts at / and is the only drive
public static string[] GetLogicalDrives() => new string[] { "/" };
public static string[] GetLogicalDrives() => DriveInfoInternal.GetLogicalDrives();

// In the mono runtime, this maps to gethostname, which returns 'emscripten'.
// Returning the value here allows us to exclude more of the runtime.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.IO
{
/// <summary>Contains internal volume helpers that are shared between many projects.</summary>
internal static partial class DriveInfoInternal
{
internal static string[] GetLogicalDrives() => new string[] { "/" };
}
}

0 comments on commit a28a47a

Please sign in to comment.