You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@@ -26,10 +26,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
|
||||
{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{29C14AD7-DC03-45DC-897D-8DACC762707E}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
|
||||
@@ -2,7 +2,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>
|
||||
<AssemblyVersion>4.1.1.0</AssemblyVersion>
|
||||
<AssemblyKey>MSFT</AssemblyKey>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsUAP>true</IsUAP>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
kernel32.dll!GetDriveTypeW
|
||||
kernel32.dll!GetLogicalDrives
|
||||
kernel32.dll!GetVolumeInformationW
|
||||
kernel32.dll!SetErrorMode
|
||||
kernel32.dll!SetThreadErrorMode
|
||||
kernel32.dll!SetVolumeLabelW
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
<ProjectGuid>{29C14AD7-DC03-45DC-897D-8DACC762707E}</ProjectGuid>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</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'" />
|
||||
@@ -49,8 +48,8 @@
|
||||
<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 Include="$(CommonPath)\Interop\Windows\kernel32\Interop.SetThreadErrorMode.cs">
|
||||
<Link>Common\Interop\Windows\Interop.SetThreadErrorMode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.SecurityOptions.cs">
|
||||
<Link>Common\Interop\Windows\Interop.SecurityOptions.cs</Link>
|
||||
|
||||
@@ -67,7 +67,8 @@ namespace System.IO
|
||||
StringBuilder fileSystemName = new StringBuilder(fileSystemNameLen);
|
||||
int serialNumber, maxFileNameLen, fileSystemFlags;
|
||||
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
uint oldMode;
|
||||
bool success = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetVolumeInformation(Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen);
|
||||
@@ -78,7 +79,8 @@ namespace System.IO
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
if (success)
|
||||
Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
|
||||
}
|
||||
return fileSystemName.ToString();
|
||||
}
|
||||
@@ -90,7 +92,8 @@ namespace System.IO
|
||||
get
|
||||
{
|
||||
long userBytes, totalBytes, freeBytes;
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
uint oldMode;
|
||||
bool success = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes);
|
||||
@@ -99,7 +102,8 @@ namespace System.IO
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
if (success)
|
||||
Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
|
||||
}
|
||||
return userBytes;
|
||||
}
|
||||
@@ -111,7 +115,8 @@ namespace System.IO
|
||||
get
|
||||
{
|
||||
long userBytes, totalBytes, freeBytes;
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
uint oldMode;
|
||||
bool success = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes);
|
||||
@@ -120,7 +125,8 @@ namespace System.IO
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
if (success)
|
||||
Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
|
||||
}
|
||||
return freeBytes;
|
||||
}
|
||||
@@ -134,7 +140,8 @@ namespace System.IO
|
||||
// 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);
|
||||
uint oldMode;
|
||||
bool success = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes);
|
||||
@@ -143,7 +150,7 @@ namespace System.IO
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
|
||||
}
|
||||
return totalBytes;
|
||||
}
|
||||
@@ -174,7 +181,8 @@ namespace System.IO
|
||||
StringBuilder fileSystemName = new StringBuilder(fileSystemNameLen);
|
||||
int serialNumber, maxFileNameLen, fileSystemFlags;
|
||||
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
uint oldMode;
|
||||
bool success = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.GetVolumeInformation(Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen);
|
||||
@@ -190,14 +198,16 @@ namespace System.IO
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
if (success)
|
||||
Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
|
||||
}
|
||||
return volumeName.ToString();
|
||||
}
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
set
|
||||
{
|
||||
uint oldMode = Interop.Kernel32.SetErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS);
|
||||
uint oldMode;
|
||||
bool success = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
|
||||
try
|
||||
{
|
||||
bool r = Interop.Kernel32.SetVolumeLabel(Name, value);
|
||||
@@ -212,7 +222,8 @@ namespace System.IO
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interop.Kernel32.SetErrorMode(oldMode);
|
||||
if (success)
|
||||
Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,12 @@ namespace System.IO
|
||||
private DriveInfo(SerializationInfo info, StreamingContext context) :
|
||||
this((string)info.GetValue("_name", typeof(string)))
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("_name", _name, typeof(String));
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public string Name => _name;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace System.IO
|
||||
|
||||
protected DriveNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using System;
|
||||
namespace System.IO
|
||||
{
|
||||
// Matches Win32's DRIVE_XXX #defines from winbase.h
|
||||
[Serializable]
|
||||
public enum DriveType
|
||||
{
|
||||
Unknown = 0,
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
netstandard-Unix;
|
||||
netstandard-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// 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.Linq;
|
||||
using Xunit;
|
||||
|
||||
@@ -15,9 +16,9 @@ namespace System.IO.FileSystem.DriveInfoTests
|
||||
{
|
||||
Assert.All(
|
||||
new[] { "", "\0", "\0/" },
|
||||
driveName => Assert.Throws<ArgumentException>("driveName", () => { new DriveInfo(driveName); }));
|
||||
driveName => AssertExtensions.Throws<ArgumentException>("driveName", () => { new DriveInfo(driveName); }));
|
||||
|
||||
Assert.Throws<ArgumentNullException>("driveName", () => { new DriveInfo(null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("driveName", () => { new DriveInfo(null); });
|
||||
|
||||
Assert.Equal("/", new DriveInfo("/").Name);
|
||||
}
|
||||
|
||||
@@ -59,11 +59,38 @@ namespace System.IO.FileSystem.DriveInfoTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDriveProperties_AppContainer()
|
||||
{
|
||||
DriveInfo validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
bool isReady = validDrive.IsReady;
|
||||
Assert.NotNull(validDrive.Name);
|
||||
Assert.NotNull(validDrive.RootDirectory.Name);
|
||||
|
||||
if (PlatformDetection.IsWinRT)
|
||||
{
|
||||
Assert.Throws<UnauthorizedAccessException>(() => validDrive.AvailableFreeSpace);
|
||||
Assert.Throws<UnauthorizedAccessException>(() => validDrive.DriveFormat);
|
||||
Assert.Throws<UnauthorizedAccessException>(() => validDrive.TotalFreeSpace);
|
||||
Assert.Throws<UnauthorizedAccessException>(() => validDrive.TotalSize);
|
||||
Assert.Throws<UnauthorizedAccessException>(() => validDrive.VolumeLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.NotNull(validDrive.DriveFormat);
|
||||
Assert.True(validDrive.AvailableFreeSpace > 0);
|
||||
Assert.True(validDrive.TotalFreeSpace > 0);
|
||||
Assert.True(validDrive.TotalSize > 0);
|
||||
Assert.NotNull(validDrive.VolumeLabel);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Accessing drive format is not permitted inside an AppContainer.")]
|
||||
public void TestDriveFormat()
|
||||
{
|
||||
var validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
DriveInfo validDrive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
const int volNameLen = 50;
|
||||
StringBuilder volumeName = new StringBuilder(volNameLen);
|
||||
const int fileSystemNameLen = 50;
|
||||
@@ -71,6 +98,7 @@ namespace System.IO.FileSystem.DriveInfoTests
|
||||
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);
|
||||
@@ -154,22 +182,35 @@ namespace System.IO.FileSystem.DriveInfoTests
|
||||
[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);
|
||||
void DoDriveCheck()
|
||||
{
|
||||
// Get Volume Label - valid drive
|
||||
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)
|
||||
DriveInfo validDrive = DriveInfo.GetDrives().First(d => d.DriveType == DriveType.Fixed);
|
||||
bool volumeInformationSuccess = GetVolumeInformation(validDrive.Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileNameLen);
|
||||
|
||||
if (volumeInformationSuccess)
|
||||
{
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
if (PlatformDetection.IsWinRT)
|
||||
{
|
||||
Assert.Equal(volumeName.ToString(), validDrive.VolumeLabel);
|
||||
Assert.Throws<UnauthorizedAccessException>(() => DoDriveCheck());
|
||||
}
|
||||
else // if we can't compare the volumeName, we should at least check that getting it doesn't throw
|
||||
else
|
||||
{
|
||||
var name = validDrive.VolumeLabel;
|
||||
DoDriveCheck();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +219,13 @@ namespace System.IO.FileSystem.DriveInfoTests
|
||||
public void SetVolumeLabel_Roundtrips()
|
||||
{
|
||||
DriveInfo drive = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).First();
|
||||
// Inside an AppContainer access to VolumeLabel is denied.
|
||||
if (PlatformDetection.IsWinRT)
|
||||
{
|
||||
Assert.Throws<UnauthorizedAccessException>(() => drive.VolumeLabel);
|
||||
return;
|
||||
}
|
||||
|
||||
string currentLabel = drive.VolumeLabel;
|
||||
try
|
||||
{
|
||||
@@ -212,7 +260,7 @@ namespace System.IO.FileSystem.DriveInfoTests
|
||||
[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)]
|
||||
[DllImport("kernel32.dll", SetLastError = true, EntryPoint = "GetDriveTypeW", CharSet = CharSet.Unicode)]
|
||||
internal static extern int GetDriveType(string drive);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
|
||||
@@ -5,11 +5,16 @@
|
||||
<ProjectGuid>{7D9E5F2F-5677-40FC-AD04-FA7D603E4806}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="DriveInfo.Unix.Tests.cs" />
|
||||
<Compile Include="DriveInfo.Windows.Tests.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
|
||||
<Link>Common\System\AssertExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="DriveInfo.Unix.Tests.cs" Condition="'$(TargetsUnix)' == 'true'" />
|
||||
<Compile Include="DriveInfo.Windows.Tests.cs" Condition="'$(TargetsWindows)' == 'true'" />
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>Common\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user