public static System.DateTime GetLastAccessTimeUtc(string path) { return default(System.DateTime); }
public static System.DateTime GetLastWriteTime(string path) { return default(System.DateTime); }
public static System.DateTime GetLastWriteTimeUtc(string path) { return default(System.DateTime); }
+ public static string[] GetLogicalDrives() { return default(string[]); }
public static System.IO.DirectoryInfo GetParent(string path) { return default(System.IO.DirectoryInfo); }
public static void Move(string sourceDirName, string destDirName) { }
public static void SetCreationTime(string path, System.DateTime creationTime) { }
<Compile Include="$(CommonPath)\Interop\Windows\mincore\Interop.CopyFile.cs">
<Link>Common\Interop\Windows\Interop.CopyFile.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)\Interop\Windows\mincore\Interop.GetLogicalDrive.cs">
+ <Link>Common\Interop\Windows\Interop.GetLogicalDrive.cs</Link>
+ </Compile>
+ <Compile Include="System\IO\Directory.Win32.cs" />
<Compile Include="System\IO\FileSystem.Current.Win32.cs" />
<Compile Include="System\IO\FileSystemInfo.Win32.cs" />
<Compile Include="$(CommonPath)\Interop\Windows\mincore\Interop.CreateFile.cs">
<Compile Include="$(CommonPath)\Interop\Windows\mincore\WinRT\Interop.SetErrorMode.cs">
<Link>Common\Interop\Windows\WinRT\Interop.SetErrorMode.cs</Link>
</Compile>
+ <Compile Include="System\IO\Directory.WinRT.cs" />
<Compile Include="System\IO\FileSystem.Current.MuxWin32WinRT.cs" />
<Compile Include="System\IO\FileSystemInfo.WinRT.cs" />
<Compile Include="System\IO\MultiplexingWin32WinRTFileSystem.cs" />
<!-- Unix -->
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" />
+ <Compile Include="System\IO\Directory.Unix.cs" />
<Compile Include="System\IO\FileStream.Unix.cs" />
<Compile Include="System\IO\FileSystem.Current.Unix.cs" />
<Compile Include="System\IO\FileSystemInfo.Unix.cs" />
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.IO
+{
+ public static partial class Directory
+ {
+ public static string[] GetLogicalDrives()
+ {
+ throw new PlatformNotSupportedException();
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.IO
+{
+ public static partial class Directory
+ {
+ public static string[] GetLogicalDrives()
+ {
+ int drives = Interop.mincore.GetLogicalDrives();
+ if (drives == 0)
+ throw Win32Marshal.GetExceptionForLastWin32Error();
+
+ uint d = (uint)drives;
+ int count = 0;
+ while (d != 0)
+ {
+ if (((int)d & 1) != 0) count++;
+ d >>= 1;
+ }
+ string[] result = new string[count];
+ char[] root = new char[] { 'A', ':', '\\' };
+ d = (uint)drives;
+ count = 0;
+ while (d != 0)
+ {
+ if (((int)d & 1) != 0)
+ {
+ result[count++] = new string(root);
+ }
+ d >>= 1;
+ root[0]++;
+ }
+ return result;
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.IO
+{
+ public static partial class Directory
+ {
+ public static string[] GetLogicalDrives()
+ {
+ throw new PlatformNotSupportedException();
+ }
+ }
+}
namespace System.IO
{
- public static class Directory
+ public static partial class Directory
{
public static DirectoryInfo GetParent(String path)
{
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Linq;
+using System.Runtime.InteropServices;
+using Xunit;
+
+namespace System.IO.Tests
+{
+ public class Directory_GetLogicalDrives
+ {
+ [Fact]
+ [PlatformSpecific(PlatformID.AnyUnix)]
+ public void ThrowsPlatformNotSupported_Unix()
+ {
+ Assert.Throws<PlatformNotSupportedException>(() => Directory.GetLogicalDrives());
+ }
+
+ [Fact]
+ [PlatformSpecific(PlatformID.Windows)]
+ public void GetsValidDriveStrings_Windows()
+ {
+ string[] drives = Directory.GetLogicalDrives();
+ Assert.NotEmpty(drives);
+ Assert.All(drives, d => Assert.Matches(@"^[A-Z]:\\$", d));
+ }
+ }
+}
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Windows_Debug</Configuration>
<Compile Include="DirectoryInfo\Root.cs" />
<Compile Include="Directory\EnumerableAPIs.cs" />
<Compile Include="Directory\GetFileSystemEntries_str_str_so.cs" />
+ <Compile Include="Directory\GetLogicalDrives.cs" />
<Compile Include="Directory\GetParent.cs" />
<Compile Include="FileInfo\GetSetAttributes.cs" />
<Compile Include="FileInfo\Length.cs" />