You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
81
external/corefx/src/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln
vendored
Normal file
81
external/corefx/src/System.IO.FileSystem.DriveInfo/System.IO.FileSystem.DriveInfo.sln
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.FileSystem.DriveInfo.Tests", "tests\System.IO.FileSystem.DriveInfo.Tests.csproj", "{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E} = {29C14AD7-DC03-45DC-897D-8DACC762707E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.FileSystem.DriveInfo", "src\System.IO.FileSystem.DriveInfo.csproj", "{29C14AD7-DC03-45DC-897D-8DACC762707E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU
|
||||
ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU
|
||||
DebugNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU = DebugNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU
|
||||
ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU = ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU
|
||||
DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU
|
||||
ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU
|
||||
DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU = DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU
|
||||
ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU = ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU
|
||||
DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
|
||||
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
|
||||
DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU
|
||||
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
external/corefx/src/System.IO.FileSystem.DriveInfo/dir.props
vendored
Normal file
8
external/corefx/src/System.IO.FileSystem.DriveInfo/dir.props
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.1.0.0</AssemblyVersion>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
9
external/corefx/src/System.IO.FileSystem.DriveInfo/ref/Configurations.props
vendored
Normal file
9
external/corefx/src/System.IO.FileSystem.DriveInfo/ref/Configurations.props
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netcoreapp;
|
||||
uap;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
44
external/corefx/src/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.cs
vendored
Normal file
44
external/corefx/src/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.cs
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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.
|
||||
// ------------------------------------------------------------------------------
|
||||
// Changes to this file must follow the http://aka.ms/api-review process.
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
public sealed partial class DriveInfo : System.Runtime.Serialization.ISerializable
|
||||
{
|
||||
public DriveInfo(string driveName) { }
|
||||
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
|
||||
public long AvailableFreeSpace { get { throw null; } }
|
||||
public string DriveFormat { get { throw null; } }
|
||||
public System.IO.DriveType DriveType { get { throw null; } }
|
||||
public bool IsReady { get { throw null; } }
|
||||
public string Name { get { throw null; } }
|
||||
public System.IO.DirectoryInfo RootDirectory { get { throw null; } }
|
||||
public long TotalFreeSpace { get { throw null; } }
|
||||
public long TotalSize { get { throw null; } }
|
||||
public string VolumeLabel { get { throw null; } set { } }
|
||||
public static System.IO.DriveInfo[] GetDrives() { throw null; }
|
||||
public override string ToString() { throw null; }
|
||||
}
|
||||
public partial class DriveNotFoundException : System.IO.IOException
|
||||
{
|
||||
public DriveNotFoundException() { }
|
||||
public DriveNotFoundException(string message) { }
|
||||
public DriveNotFoundException(string message, System.Exception innerException) { }
|
||||
protected DriveNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
|
||||
}
|
||||
public enum DriveType
|
||||
{
|
||||
CDRom = 5,
|
||||
Fixed = 3,
|
||||
Network = 4,
|
||||
NoRootDirectory = 1,
|
||||
Ram = 6,
|
||||
Removable = 2,
|
||||
Unknown = 0,
|
||||
}
|
||||
}
|
||||
18
external/corefx/src/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.csproj
vendored
Normal file
18
external/corefx/src/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.csproj
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="System.IO.FileSystem.DriveInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\System.IO\ref\System.IO.csproj" />
|
||||
<ProjectReference Include="..\..\System.IO.FileSystem.Primitives\ref\System.IO.FileSystem.Primitives.csproj" />
|
||||
<ProjectReference Include="..\..\System.IO.FileSystem\ref\System.IO.FileSystem.csproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
10
external/corefx/src/System.IO.FileSystem.DriveInfo/src/Configurations.props
vendored
Normal file
10
external/corefx/src/System.IO.FileSystem.DriveInfo/src/Configurations.props
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netcoreapp-Unix;
|
||||
netcoreapp-Windows_NT;
|
||||
net463-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
180
external/corefx/src/System.IO.FileSystem.DriveInfo/src/Resources/Strings.resx
vendored
Normal file
180
external/corefx/src/System.IO.FileSystem.DriveInfo/src/Resources/Strings.resx
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Arg_MustBeDriveLetterOrRootDir" xml:space="preserve">
|
||||
<value>Drive name must be a root directory ('C:\\') or a drive letter ('C').</value>
|
||||
</data>
|
||||
<data name="Arg_MustBeNonEmptyDriveName" xml:space="preserve">
|
||||
<value>Drive name must not be empty.</value>
|
||||
</data>
|
||||
<data name="Arg_InvalidDriveChars" xml:space="preserve">
|
||||
<value>Illegal characters in drive name '{0}'.</value>
|
||||
</data>
|
||||
<data name="Argument_InvalidPathChars" xml:space="preserve">
|
||||
<value>Illegal characters in path.</value>
|
||||
</data>
|
||||
<data name="ArgumentOutOfRange_FileLengthTooBig" xml:space="preserve">
|
||||
<value>Specified file length was too large for the file system.</value>
|
||||
</data>
|
||||
<data name="InvalidOperation_SetVolumeLabelFailed" xml:space="preserve">
|
||||
<value>Volume labels can only be set for writable local volumes.</value>
|
||||
</data>
|
||||
<data name="IO_AlreadyExists_Name" xml:space="preserve">
|
||||
<value>Cannot create '{0}' because a file or directory with the same name already exists.</value>
|
||||
</data>
|
||||
<data name="IO_DriveNotFound" xml:space="preserve">
|
||||
<value>Could not find the drive. The drive might not be ready or might not be mapped.</value>
|
||||
</data>
|
||||
<data name="IO_DriveNotFound_Drive" xml:space="preserve">
|
||||
<value>Could not find the drive '{0}'. The drive might not be ready or might not be mapped.</value>
|
||||
</data>
|
||||
<data name="IO_FileExists_Name" xml:space="preserve">
|
||||
<value>The file '{0}' already exists.</value>
|
||||
</data>
|
||||
<data name="IO_FileNotFound" xml:space="preserve">
|
||||
<value>Unable to find the specified file.</value>
|
||||
</data>
|
||||
<data name="IO_FileNotFound_FileName" xml:space="preserve">
|
||||
<value>Could not find file '{0}'.</value>
|
||||
</data>
|
||||
<data name="IO_PathNotFound_NoPathName" xml:space="preserve">
|
||||
<value>Could not find a part of the path.</value>
|
||||
</data>
|
||||
<data name="IO_PathNotFound_Path" xml:space="preserve">
|
||||
<value>Could not find a part of the path '{0}'.</value>
|
||||
</data>
|
||||
<data name="IO_PathTooLong" xml:space="preserve">
|
||||
<value>The specified file name or path is too long, or a component of the specified path is too long.</value>
|
||||
</data>
|
||||
<data name="IO_SharingViolation_File" xml:space="preserve">
|
||||
<value>The process cannot access the file '{0}' because it is being used by another process.</value>
|
||||
</data>
|
||||
<data name="IO_SharingViolation_NoFileName" xml:space="preserve">
|
||||
<value>The process cannot access the file because it is being used by another process.</value>
|
||||
</data>
|
||||
<data name="UnauthorizedAccess_IODenied_NoPathName" xml:space="preserve">
|
||||
<value>Access to the path is denied.</value>
|
||||
</data>
|
||||
<data name="UnauthorizedAccess_IODenied_Path" xml:space="preserve">
|
||||
<value>Access to the path '{0}' is denied.</value>
|
||||
</data>
|
||||
<data name="UnknownError_Num" xml:space="preserve">
|
||||
<value>Unknown error '{0}'.</value>
|
||||
</data>
|
||||
</root>
|
||||
117
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj
vendored
Normal file
117
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<RootNamespace>System.IO.FileSystem.DriveInfo</RootNamespace>
|
||||
<AssemblyName>System.IO.FileSystem.DriveInfo</AssemblyName>
|
||||
<ProjectGuid>{29C14AD7-DC03-45DC-897D-8DACC762707E}</ProjectGuid>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'net463'">true</IsPartialFacadeAssembly>
|
||||
</PropertyGroup>
|
||||
<!-- Help VS understand available configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
|
||||
<Compile Include="System\IO\DriveInfo.cs" />
|
||||
<Compile Include="System\IO\DriveNotFoundException.cs" />
|
||||
<Compile Include="System\IO\DriveType.cs" />
|
||||
<Compile Include="$(CommonPath)\System\HResults.cs">
|
||||
<Link>Common\System\HResults.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\IO\PathInternal.cs">
|
||||
<Link>Common\System\IO\PathInternal.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseSensitivity.cs">
|
||||
<Link>Common\System\IO\PathInternal.CaseSensitivity.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' And '$(TargetGroup)' == 'netcoreapp' ">
|
||||
<Compile Include="System\IO\Error.cs" />
|
||||
<Compile Include="System\IO\DriveInfo.Windows.cs" />
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
|
||||
<Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.GetDriveType.cs">
|
||||
<Link>Common\Interop\Windows\Interop.GetDriveType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.GetVolumeInformation.cs">
|
||||
<Link>Common\Interop\Windows\Interop.GetVolumeInformation.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.GetLogicalDrive.cs">
|
||||
<Link>Common\Interop\Windows\Interop.GetLogicalDrive.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.GetDiskFreeSpaceEx.cs">
|
||||
<Link>Common\Interop\Windows\Interop.GetDiskFreeSpaceEx.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.SetVolumeLabel.cs">
|
||||
<Link>Common\Interop\Windows\Interop.SetVolumeLabel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.SetErrorMode.cs">
|
||||
<Link>Common\Interop\Windows\Interop.SetErrorMode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.SecurityOptions.cs">
|
||||
<Link>Common\Interop\Windows\Interop.SecurityOptions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.FileOperations.cs">
|
||||
<Link>Common\Interop\Windows\Interop.FileOperations.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Errors.cs">
|
||||
<Link>Common\Interop\Windows\Interop.Errors.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.FormatMessage.cs">
|
||||
<Link>Common\Interop\Windows\Interop.FormatMessage.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\IO\Win32Marshal.cs">
|
||||
<Link>Common\System\IO\Win32Marshal.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\IO\DriveInfoInternal.Win32.cs">
|
||||
<Link>Common\System\IO\DriveInfoInternal.Win32.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\IO\PathInternal.Windows.cs">
|
||||
<Link>Common\System\IO\PathInternal.Windows.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetsUnix)' == 'true' And '$(TargetGroup)' == 'netcoreapp' ">
|
||||
<Compile Include="System\IO\DriveInfo.Unix.cs" />
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\Interop.Libraries.cs">
|
||||
<Link>Common\Interop\Unix\Interop.Libraries.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\Interop.Errors.cs">
|
||||
<Link>Common\Interop\Unix\Interop.Errors.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\Interop.IOErrors.cs">
|
||||
<Link>Common\Interop\Unix\Interop.IOErrors.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\IO\PathInternal.Unix.cs">
|
||||
<Link>Common\System\IO\PathInternal.Unix.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.PathConf.cs">
|
||||
<Link>Common\Interop\Unix\Interop.PathConf.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.MountPoints.cs">
|
||||
<Link>Common\Interop\Unix\Interop.MountPoints.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.MountPoints.FormatInfo.cs">
|
||||
<Link>Common\Interop\Unix\Interop.MountPoints.FormatInfo.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'net463'">
|
||||
<TargetingPackReference Include="mscorlib" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Diagnostics.Contracts" />
|
||||
<Reference Include="System.Diagnostics.Debug" />
|
||||
<Reference Include="System.Diagnostics.Tools" />
|
||||
<Reference Include="System.IO.FileSystem" />
|
||||
<Reference Include="System.Resources.ResourceManager" />
|
||||
<Reference Include="System.Runtime" />
|
||||
<Reference Include="System.Runtime.Extensions" />
|
||||
<Reference Include="System.Runtime.InteropServices" />
|
||||
<Reference Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
146
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.Unix.cs
vendored
Normal file
146
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.Unix.cs
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Security;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
public sealed partial class DriveInfo
|
||||
{
|
||||
public static DriveInfo[] GetDrives()
|
||||
{
|
||||
string[] mountPoints = Interop.Sys.GetAllMountPoints();
|
||||
DriveInfo[] info = new DriveInfo[mountPoints.Length];
|
||||
for (int i = 0; i < info.Length; i++)
|
||||
{
|
||||
info[i] = new DriveInfo(mountPoints[i]);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
private static string NormalizeDriveName(string driveName)
|
||||
{
|
||||
if (driveName.Contains("\0"))
|
||||
{
|
||||
throw new ArgumentException(SR.Format(SR.Arg_InvalidDriveChars, driveName), nameof(driveName));
|
||||
}
|
||||
if (driveName.Length == 0)
|
||||
{
|
||||
throw new ArgumentException(SR.Arg_MustBeNonEmptyDriveName, nameof(driveName));
|
||||
}
|
||||
return driveName;
|
||||
}
|
||||
|
||||
public DriveType DriveType
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
DriveType type;
|
||||
int result = Interop.Sys.GetFormatInfoForMountPoint(Name, out type);
|
||||
if (result == 0)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
else
|
||||
{
|
||||
Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo();
|
||||
|
||||
// This is one of the few properties that doesn't throw on failure,
|
||||
// instead returning a value from the enum.
|
||||
switch (errorInfo.Error)
|
||||
{
|
||||
case Interop.Error.ELOOP:
|
||||
case Interop.Error.ENAMETOOLONG:
|
||||
case Interop.Error.ENOENT:
|
||||
case Interop.Error.ENOTDIR:
|
||||
return DriveType.NoRootDirectory;
|
||||
default:
|
||||
return DriveType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DriveFormat
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
string format = string.Empty;
|
||||
CheckStatfsResultAndThrowIfNecessary(Interop.Sys.GetFormatInfoForMountPoint(Name, out format));
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
public long AvailableFreeSpace
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
Interop.Sys.MountPointInformation mpi = default(Interop.Sys.MountPointInformation);
|
||||
CheckStatfsResultAndThrowIfNecessary(Interop.Sys.GetSpaceInfoForMountPoint(Name, out mpi));
|
||||
return checked((long)mpi.AvailableFreeSpace);
|
||||
}
|
||||
}
|
||||
|
||||
public long TotalFreeSpace
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
Interop.Sys.MountPointInformation mpi = default(Interop.Sys.MountPointInformation);
|
||||
CheckStatfsResultAndThrowIfNecessary(Interop.Sys.GetSpaceInfoForMountPoint(Name, out mpi));
|
||||
return checked((long)mpi.TotalFreeSpace);
|
||||
}
|
||||
}
|
||||
|
||||
public long TotalSize
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
Interop.Sys.MountPointInformation mpi = default(Interop.Sys.MountPointInformation);
|
||||
CheckStatfsResultAndThrowIfNecessary(Interop.Sys.GetSpaceInfoForMountPoint(Name, out mpi));
|
||||
return checked((long)mpi.TotalSize);
|
||||
}
|
||||
}
|
||||
|
||||
public string VolumeLabel
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
[SecuritySafeCritical]
|
||||
set
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// ---- PAL layer ends here ----
|
||||
// -----------------------------
|
||||
|
||||
private void CheckStatfsResultAndThrowIfNecessary(int result)
|
||||
{
|
||||
if (result != 0)
|
||||
{
|
||||
var errorInfo = Interop.Sys.GetLastErrorInfo();
|
||||
if (errorInfo.Error == Interop.Error.ENOENT)
|
||||
{
|
||||
throw new DriveNotFoundException(SR.Format(SR.IO_DriveNotFound_Drive, Name)); // match Win32
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Interop.GetExceptionForIoErrno(errorInfo, isDirectory: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
220
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.Windows.cs
vendored
Normal file
220
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.Windows.cs
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
// 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;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
public sealed partial class DriveInfo
|
||||
{
|
||||
private static string NormalizeDriveName(string driveName)
|
||||
{
|
||||
Debug.Assert(driveName != null);
|
||||
|
||||
string name;
|
||||
|
||||
if (driveName.Length == 1)
|
||||
name = driveName + ":\\";
|
||||
else
|
||||
{
|
||||
// GetPathRoot does not check all invalid characters
|
||||
if (PathInternal.HasIllegalCharacters(driveName))
|
||||
throw new ArgumentException(SR.Format(SR.Arg_InvalidDriveChars, driveName), nameof(driveName));
|
||||
|
||||
name = Path.GetPathRoot(driveName);
|
||||
// Disallow null or empty drive letters and UNC paths
|
||||
if (name == null || name.Length == 0 || name.StartsWith("\\\\", StringComparison.Ordinal))
|
||||
throw new ArgumentException(SR.Arg_MustBeDriveLetterOrRootDir);
|
||||
}
|
||||
// We want to normalize to have a trailing backslash so we don't have two equivalent forms and
|
||||
// because some Win32 API don't work without it.
|
||||
if (name.Length == 2 && name[1] == ':')
|
||||
{
|
||||
name = name + "\\";
|
||||
}
|
||||
|
||||
// Now verify that the drive letter could be a real drive name.
|
||||
// On Windows this means it's between A and Z, ignoring case.
|
||||
char letter = driveName[0];
|
||||
if (!((letter >= 'A' && letter <= 'Z') || (letter >= 'a' && letter <= 'z')))
|
||||
throw new ArgumentException(SR.Arg_MustBeDriveLetterOrRootDir);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public DriveType DriveType
|
||||
{
|
||||
[System.Security.SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
// GetDriveType can't fail
|
||||
return (DriveType)Interop.Kernel32.GetDriveType(Name);
|
||||
}
|
||||
}
|
||||
|
||||
public String DriveFormat
|
||||
{
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
get
|
||||
{
|
||||
const int volNameLen = 50;
|
||||
StringBuilder volumeName = new StringBuilder(volNameLen);
|
||||
const int fileSystemNameLen = 50;
|
||||
StringBuilder fileSystemName = new StringBuilder(fileSystemNameLen);
|
||||
int serialNumber, maxFileNameLen, fileSystemFlags;
|
||||
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetVolumeInformation(Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen);
|
||||
if (!r)
|
||||
{
|
||||
throw Error.GetExceptionForLastWin32DriveError(Name);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
}
|
||||
return fileSystemName.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public long AvailableFreeSpace
|
||||
{
|
||||
[System.Security.SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
long userBytes, totalBytes, freeBytes;
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes);
|
||||
if (!r)
|
||||
throw Error.GetExceptionForLastWin32DriveError(Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
}
|
||||
return userBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public long TotalFreeSpace
|
||||
{
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
get
|
||||
{
|
||||
long userBytes, totalBytes, freeBytes;
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes);
|
||||
if (!r)
|
||||
throw Error.GetExceptionForLastWin32DriveError(Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
}
|
||||
return freeBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public long TotalSize
|
||||
{
|
||||
[System.Security.SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
// Don't cache this, to handle variable sized floppy drives
|
||||
// or other various removable media drives.
|
||||
long userBytes, totalBytes, freeBytes;
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes);
|
||||
if (!r)
|
||||
throw Error.GetExceptionForLastWin32DriveError(Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
}
|
||||
return totalBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public static DriveInfo[] GetDrives()
|
||||
{
|
||||
string[] drives = DriveInfoInternal.GetLogicalDrives();
|
||||
DriveInfo[] result = new DriveInfo[drives.Length];
|
||||
for (int i = 0; i < drives.Length; i++)
|
||||
{
|
||||
result[i] = new DriveInfo(drives[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Null is a valid volume label.
|
||||
public String VolumeLabel
|
||||
{
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
get
|
||||
{
|
||||
// NTFS uses a limit of 32 characters for the volume label,
|
||||
// as of Windows Server 2003.
|
||||
const int volNameLen = 50;
|
||||
StringBuilder volumeName = new StringBuilder(volNameLen);
|
||||
const int fileSystemNameLen = 50;
|
||||
StringBuilder fileSystemName = new StringBuilder(fileSystemNameLen);
|
||||
int serialNumber, maxFileNameLen, fileSystemFlags;
|
||||
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetVolumeInformation(Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen);
|
||||
if (!r)
|
||||
{
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
// Win9x appears to return ERROR_INVALID_DATA when a
|
||||
// drive doesn't exist.
|
||||
if (errorCode == Interop.Errors.ERROR_INVALID_DATA)
|
||||
errorCode = Interop.Errors.ERROR_INVALID_DRIVE;
|
||||
throw Error.GetExceptionForWin32DriveError(errorCode, Name);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
}
|
||||
return volumeName.ToString();
|
||||
}
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
set
|
||||
{
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.SetVolumeLabel(Name, value);
|
||||
if (!r)
|
||||
{
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
// Provide better message
|
||||
if (errorCode == Interop.Errors.ERROR_ACCESS_DENIED)
|
||||
throw new UnauthorizedAccessException(SR.InvalidOperation_SetVolumeLabelFailed);
|
||||
throw Error.GetExceptionForWin32DriveError(errorCode, Name);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.cs
vendored
Normal file
42
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.cs
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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.Runtime.Serialization;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
[Serializable]
|
||||
public sealed partial class DriveInfo : ISerializable
|
||||
{
|
||||
private readonly string _name;
|
||||
|
||||
public DriveInfo(string driveName)
|
||||
{
|
||||
if (driveName == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(driveName));
|
||||
}
|
||||
|
||||
_name = NormalizeDriveName(driveName);
|
||||
}
|
||||
|
||||
private DriveInfo(SerializationInfo info, StreamingContext context) :
|
||||
this((string)info.GetValue("_name", typeof(string)))
|
||||
{
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("_name", _name, typeof(String));
|
||||
}
|
||||
|
||||
public string Name => _name;
|
||||
|
||||
public bool IsReady => Directory.Exists(Name);
|
||||
|
||||
public DirectoryInfo RootDirectory => new DirectoryInfo(Name);
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
35
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs
vendored
Normal file
35
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveNotFoundException.cs
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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.Runtime.Serialization;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
//Thrown when trying to access a drive that is not available.
|
||||
[Serializable]
|
||||
public class DriveNotFoundException : IOException
|
||||
{
|
||||
public DriveNotFoundException()
|
||||
: base(SR.IO_DriveNotFound)
|
||||
{
|
||||
HResult = HResults.COR_E_DIRECTORYNOTFOUND;
|
||||
}
|
||||
|
||||
public DriveNotFoundException(string message)
|
||||
: base(message)
|
||||
{
|
||||
HResult = HResults.COR_E_DIRECTORYNOTFOUND;
|
||||
}
|
||||
|
||||
public DriveNotFoundException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
HResult = HResults.COR_E_DIRECTORYNOTFOUND;
|
||||
}
|
||||
|
||||
protected DriveNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
21
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveType.cs
vendored
Normal file
21
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveType.cs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// 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;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
// Matches Win32's DRIVE_XXX #defines from winbase.h
|
||||
[Serializable]
|
||||
public enum DriveType
|
||||
{
|
||||
Unknown = 0,
|
||||
NoRootDirectory = 1,
|
||||
Removable = 2,
|
||||
Fixed = 3,
|
||||
Network = 4,
|
||||
CDRom = 5,
|
||||
Ram = 6
|
||||
}
|
||||
}
|
||||
38
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/Error.cs
vendored
Normal file
38
external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/Error.cs
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
[Pure]
|
||||
internal static class Error
|
||||
{
|
||||
// An alternative to Win32Marshal with friendlier messages for drives
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
internal static Exception GetExceptionForLastWin32DriveError(String driveName)
|
||||
{
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
return GetExceptionForWin32DriveError(errorCode, driveName);
|
||||
}
|
||||
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
internal static Exception GetExceptionForWin32DriveError(int errorCode, String driveName)
|
||||
{
|
||||
switch (errorCode)
|
||||
{
|
||||
case Interop.Errors.ERROR_PATH_NOT_FOUND:
|
||||
case Interop.Errors.ERROR_INVALID_DRIVE:
|
||||
return new DriveNotFoundException(SR.Format(SR.IO_DriveNotFound_Drive, driveName));
|
||||
|
||||
default:
|
||||
return Win32Marshal.GetExceptionForWin32Error(errorCode, driveName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
external/corefx/src/System.IO.FileSystem.DriveInfo/tests/Configurations.props
vendored
Normal file
9
external/corefx/src/System.IO.FileSystem.DriveInfo/tests/Configurations.props
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard1.3-Windows_NT;
|
||||
netstandard;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
87
external/corefx/src/System.IO.FileSystem.DriveInfo/tests/DriveInfo.Unix.Tests.cs
vendored
Normal file
87
external/corefx/src/System.IO.FileSystem.DriveInfo/tests/DriveInfo.Unix.Tests.cs
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// 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 Xunit;
|
||||
|
||||
namespace System.IO.FileSystem.DriveInfoTests
|
||||
{
|
||||
public partial class DriveInfoUnixTests
|
||||
{
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
public void TestConstructor()
|
||||
{
|
||||
Assert.All(
|
||||
new[] { "", "\0", "\0/" },
|
||||
driveName => Assert.Throws<ArgumentException>("driveName", () => { new DriveInfo(driveName); }));
|
||||
|
||||
Assert.Throws<ArgumentNullException>("driveName", () => { new DriveInfo(null); });
|
||||
|
||||
Assert.Equal("/", new DriveInfo("/").Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
public void TestGetDrives()
|
||||
{
|
||||
var drives = DriveInfo.GetDrives();
|
||||
Assert.NotNull(drives);
|
||||
Assert.True(drives.Length > 0, "Expected at least one drive");
|
||||
Assert.All(drives, d => Assert.NotNull(d));
|
||||
Assert.Contains(drives, d => d.Name == "/");
|
||||
Assert.All(drives, d =>
|
||||
{
|
||||
// None of these should throw
|
||||
DriveType dt = d.DriveType;
|
||||
bool isReady = d.IsReady;
|
||||
DirectoryInfo di = d.RootDirectory;
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
public void PropertiesOfInvalidDrive()
|
||||
{
|
||||
string invalidDriveName = "NonExistentDriveName";
|
||||
var invalidDrive = new DriveInfo(invalidDriveName);
|
||||
|
||||
Assert.Throws<DriveNotFoundException>(() =>invalidDrive.AvailableFreeSpace);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.DriveFormat);
|
||||
Assert.Equal(DriveType.NoRootDirectory, invalidDrive.DriveType);
|
||||
Assert.False(invalidDrive.IsReady);
|
||||
Assert.Equal(invalidDriveName, invalidDrive.Name);
|
||||
Assert.Equal(invalidDriveName, invalidDrive.ToString());
|
||||
Assert.Equal(invalidDriveName, invalidDrive.RootDirectory.Name);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.TotalFreeSpace);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.TotalSize);
|
||||
Assert.Equal(invalidDriveName, invalidDrive.VolumeLabel); // VolumeLabel is equivalent to Name on Unix
|
||||
}
|
||||
|
||||
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/dotnet/corefx/issues/11570
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
public void PropertiesOfValidDrive()
|
||||
{
|
||||
var root = new DriveInfo("/");
|
||||
Assert.True(root.AvailableFreeSpace > 0);
|
||||
var format = root.DriveFormat;
|
||||
Assert.Equal(DriveType.Fixed, root.DriveType);
|
||||
Assert.True(root.IsReady);
|
||||
Assert.Equal("/", root.Name);
|
||||
Assert.Equal("/", root.ToString());
|
||||
Assert.Equal("/", root.RootDirectory.FullName);
|
||||
Assert.True(root.TotalFreeSpace > 0);
|
||||
Assert.True(root.TotalSize > 0);
|
||||
Assert.Equal("/", root.VolumeLabel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
public void SetVolumeLabel_Throws_PlatformNotSupportedException()
|
||||
{
|
||||
var root = new DriveInfo("/");
|
||||
Assert.Throws<PlatformNotSupportedException>(() => root.VolumeLabel = root.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
252
external/corefx/src/System.IO.FileSystem.DriveInfo/tests/DriveInfo.Windows.Tests.cs
vendored
Normal file
252
external/corefx/src/System.IO.FileSystem.DriveInfo/tests/DriveInfo.Windows.Tests.cs
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
// 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;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using Xunit;
|
||||
using System.Text;
|
||||
|
||||
namespace System.IO.FileSystem.DriveInfoTests
|
||||
{
|
||||
public class DriveInfoWindowsTests
|
||||
{
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void TestConstructor()
|
||||
{
|
||||
string[] invalidInput = { ":\0", ":", "://", @":\", ":/", @":\\", "Az", "1", "a1", @"\\share", @"\\", "c ", string.Empty, " c" };
|
||||
string[] variableInput = { "{0}", "{0}", "{0}:", "{0}:", @"{0}:\", @"{0}:\\", "{0}://" };
|
||||
|
||||
// Test Invalid input
|
||||
foreach (var input in invalidInput)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => { new DriveInfo(input); });
|
||||
}
|
||||
|
||||
// Test Null
|
||||
Assert.Throws<ArgumentNullException>(() => { new DriveInfo(null); });
|
||||
|
||||
// Test Valid DriveLetter
|
||||
var validDriveLetter = GetValidDriveLettersOnMachine().First();
|
||||
foreach (var input in variableInput)
|
||||
{
|
||||
string name = string.Format(input, validDriveLetter);
|
||||
DriveInfo dInfo = new DriveInfo(name);
|
||||
Assert.Equal(string.Format(@"{0}:\", validDriveLetter), dInfo.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void TestGetDrives()
|
||||
{
|
||||
var validExpectedDrives = GetValidDriveLettersOnMachine();
|
||||
var validActualDrives = DriveInfo.GetDrives();
|
||||
|
||||
// Test count
|
||||
Assert.Equal(validExpectedDrives.Count(), validActualDrives.Count());
|
||||
|
||||
for (int i = 0; i < validActualDrives.Count(); i++)
|
||||
{
|
||||
// Test if the driveletter is correct
|
||||
Assert.Contains(validActualDrives[i].Name[0], validExpectedDrives);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void TestDriveFormat()
|
||||
{
|
||||
var validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
const int volNameLen = 50;
|
||||
StringBuilder volumeName = new StringBuilder(volNameLen);
|
||||
const int fileSystemNameLen = 50;
|
||||
StringBuilder fileSystemName = new StringBuilder(fileSystemNameLen);
|
||||
int serialNumber, maxFileNameLen, fileSystemFlags;
|
||||
bool r = GetVolumeInformation(validDrive.Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen);
|
||||
var fileSystem = fileSystemName.ToString();
|
||||
if (r)
|
||||
{
|
||||
Assert.Equal(fileSystem, validDrive.DriveFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Throws<IOException>(() => validDrive.DriveFormat);
|
||||
}
|
||||
|
||||
// Test Invalid drive
|
||||
var invalidDrive = new DriveInfo(GetInvalidDriveLettersOnMachine().First().ToString());
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.DriveFormat);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void TestDriveType()
|
||||
{
|
||||
var validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
var expectedDriveType = GetDriveType(validDrive.Name);
|
||||
Assert.Equal((DriveType)expectedDriveType, validDrive.DriveType);
|
||||
|
||||
// Test Invalid drive
|
||||
var invalidDrive = new DriveInfo(GetInvalidDriveLettersOnMachine().First().ToString());
|
||||
Assert.Equal(invalidDrive.DriveType, DriveType.NoRootDirectory);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void TestValidDiskSpaceProperties()
|
||||
{
|
||||
bool win32Result;
|
||||
long fbUser = -1;
|
||||
long tbUser;
|
||||
long fbTotal;
|
||||
DriveInfo drive;
|
||||
|
||||
drive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
if (drive.IsReady)
|
||||
{
|
||||
win32Result = GetDiskFreeSpaceEx(drive.Name, out fbUser, out tbUser, out fbTotal);
|
||||
Assert.True(win32Result);
|
||||
|
||||
if (fbUser != drive.AvailableFreeSpace)
|
||||
Assert.True(drive.AvailableFreeSpace >= 0);
|
||||
|
||||
// valid property getters shouldn't throw
|
||||
string name = drive.Name;
|
||||
string format = drive.DriveFormat;
|
||||
Assert.Equal(name, drive.ToString());
|
||||
|
||||
// totalsize should not change for a fixed drive.
|
||||
Assert.Equal(tbUser, drive.TotalSize);
|
||||
|
||||
if (fbTotal != drive.TotalFreeSpace)
|
||||
Assert.True(drive.TotalFreeSpace >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void TestInvalidDiskProperties()
|
||||
{
|
||||
string invalidDriveName = GetInvalidDriveLettersOnMachine().First().ToString();
|
||||
var invalidDrive = new DriveInfo(invalidDriveName);
|
||||
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.AvailableFreeSpace);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.DriveFormat);
|
||||
Assert.Equal(DriveType.NoRootDirectory, invalidDrive.DriveType);
|
||||
Assert.False(invalidDrive.IsReady);
|
||||
Assert.Equal(invalidDriveName + ":\\", invalidDrive.Name);
|
||||
Assert.Equal(invalidDriveName + ":\\", invalidDrive.ToString());
|
||||
Assert.Equal(invalidDriveName + ":\\", invalidDrive.RootDirectory.FullName);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.TotalFreeSpace);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.TotalSize);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.VolumeLabel);
|
||||
Assert.Throws<DriveNotFoundException>(() => invalidDrive.VolumeLabel = null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void GetVolumeLabel_Returns_CorrectLabel()
|
||||
{
|
||||
int serialNumber, maxFileNameLen, fileSystemFlags;
|
||||
int volNameLen = 50;
|
||||
int fileNameLen = 50;
|
||||
StringBuilder volumeName = new StringBuilder(volNameLen);
|
||||
StringBuilder fileSystemName = new StringBuilder(fileNameLen);
|
||||
|
||||
// Get Volume Label - valid drive
|
||||
var validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
bool r = GetVolumeInformation(validDrive.Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileNameLen);
|
||||
if (r)
|
||||
{
|
||||
Assert.Equal(volumeName.ToString(), validDrive.VolumeLabel);
|
||||
}
|
||||
else // if we can't compare the volumeName, we should at least check that getting it doesn't throw
|
||||
{
|
||||
var name = validDrive.VolumeLabel;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void SetVolumeLabel_Roundtrips()
|
||||
{
|
||||
DriveInfo drive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
string currentLabel = drive.VolumeLabel;
|
||||
try
|
||||
{
|
||||
drive.VolumeLabel = currentLabel; // shouldn't change the state of the drive regardless of success
|
||||
}
|
||||
catch (UnauthorizedAccessException) { }
|
||||
Assert.Equal(drive.VolumeLabel, currentLabel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void VolumeLabelOnNetworkOrCdRom_Throws()
|
||||
{
|
||||
// Test setting the volume label on a Network or CD-ROM
|
||||
var noAccessDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Network || d.DriveType == DriveType.CDRom);
|
||||
foreach (var adrive in noAccessDrive)
|
||||
{
|
||||
if (adrive.IsReady)
|
||||
{
|
||||
Exception e = Assert.ThrowsAny<Exception>(() => { adrive.VolumeLabel = null; });
|
||||
Assert.True(
|
||||
e is UnauthorizedAccessException ||
|
||||
e is IOException ||
|
||||
e is SecurityException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
internal static extern int GetLogicalDrives();
|
||||
|
||||
[DllImport("kernel32.dll", EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
|
||||
internal static extern bool GetVolumeInformation(string drive, StringBuilder volumeName, int volumeNameBufLen, out int volSerialNumber, out int maxFileNameLen, out int fileSystemFlags, StringBuilder fileSystemName, int fileSystemNameBufLen);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
internal static extern int GetDriveType(string drive);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
internal static extern bool GetDiskFreeSpaceEx(string drive, out long freeBytesForUser, out long totalBytes, out long freeBytes);
|
||||
|
||||
private IEnumerable<char> GetValidDriveLettersOnMachine()
|
||||
{
|
||||
uint mask = (uint)GetLogicalDrives();
|
||||
Assert.NotEqual<uint>(mask, 0);
|
||||
|
||||
var bits = new BitArray(new int[] { (int)mask });
|
||||
for (int i = 0; i < bits.Length; i++)
|
||||
{
|
||||
var letter = (char)('A' + i);
|
||||
if (bits[i])
|
||||
yield return letter;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<char> GetInvalidDriveLettersOnMachine()
|
||||
{
|
||||
uint mask = (uint)GetLogicalDrives();
|
||||
Assert.NotEqual<uint>(mask, 0);
|
||||
|
||||
var bits = new BitArray(new int[] { (int)mask });
|
||||
for (int i = 0; i < bits.Length; i++)
|
||||
{
|
||||
var letter = (char)('A' + i);
|
||||
if (!bits[i])
|
||||
{
|
||||
if (char.IsLetter(letter))
|
||||
yield return letter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<ItemGroup>
|
||||
<Project Include="System.IO.FileSystem.DriveInfo.Tests.csproj" />
|
||||
<Project Include="System.IO.FileSystem.DriveInfo.Tests.csproj">
|
||||
<OSGroup>Windows_NT</OSGroup>
|
||||
<TestTFMs>net463</TestTFMs>
|
||||
</Project>
|
||||
<Project Include="System.IO.FileSystem.DriveInfo.Tests.csproj">
|
||||
<TargetGroup>netstandard1.3</TargetGroup>
|
||||
<OSGroup>Windows_NT</OSGroup>
|
||||
<TestTFMs>netcoreapp1.0;net46</TestTFMs>
|
||||
</Project>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="DriveInfo.Unix.Tests.cs" />
|
||||
<Compile Include="DriveInfo.Windows.Tests.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>Common\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user