Replace use of IsLinux with IsWindows

So that IsLinux can stop being overloading for OS X.
This commit is contained in:
Andrew Schwartzmeyer
2016-04-08 14:50:37 -07:00
parent 5b3840f753
commit 6f2110f38a
4 changed files with 16 additions and 28 deletions
@@ -828,7 +828,7 @@ namespace System.Management.Automation
// Porting note: if not otherwise defined, map Windows environment
// variables to their corresponding Linux counterparts
if (Platform.IsLinux() && String.IsNullOrEmpty(value))
if (!Platform.IsWindows() && String.IsNullOrEmpty(value))
{
switch (variable)
{
@@ -30,18 +30,6 @@ namespace System.Management.Automation
/// </summary>
internal static class Platform
{
// this queries specifically for Linux or OS X because they are very similar
internal static bool IsLinux()
{
#if CORECLR
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|| RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
#else
// FullCLR doesn't have a Linux version
return false;
#endif
}
// this is specifically to query for Windows, everything else is considered to be non-Windows
internal static bool IsWindows()
{
@@ -190,7 +178,7 @@ namespace System.Management.Automation
internal static bool NonWindowsIsHardLink(FileSystemInfo fileInfo)
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.IsHardLink(fileInfo);
}
@@ -200,7 +188,7 @@ namespace System.Management.Automation
internal static bool NonWindowsIsSymLink(FileSystemInfo fileInfo)
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.IsSymLink(fileInfo);
}
@@ -216,7 +204,7 @@ namespace System.Management.Automation
internal static string NonWindowsInternalGetTarget(string path)
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.FollowSymLink(path);
}
@@ -229,7 +217,7 @@ namespace System.Management.Automation
#if CORECLR
internal static string NonWindowsGetFolderPath(SpecialFolder folder)
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.GetFolderPath(folder);
}
@@ -242,7 +230,7 @@ namespace System.Management.Automation
internal static string NonWindowsInternalGetLinkType(FileSystemInfo fileInfo)
{
if (IsLinux())
if (!IsWindows())
{
if (NonWindowsIsSymLink(fileInfo))
{
@@ -263,7 +251,7 @@ namespace System.Management.Automation
internal static bool NonWindowsCreateSymbolicLink(string path, string strTargetPath, bool isDirectory)
{
if (IsLinux())
if (!IsWindows())
{
// Linux doesn't care if target is a directory or not
return LinuxPlatform.CreateSymbolicLink(path, strTargetPath);
@@ -276,7 +264,7 @@ namespace System.Management.Automation
internal static bool NonWindowsCreateHardLink(string path, string strTargetPath)
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.CreateHardLink(path, strTargetPath);
}
@@ -288,7 +276,7 @@ namespace System.Management.Automation
internal static void NonWindowsSetDate(DateTime dateToUse)
{
if (IsLinux())
if (!IsWindows())
{
LinuxPlatform.SetDateInfoInternal date = new LinuxPlatform.SetDateInfoInternal(dateToUse);
LinuxPlatform.SetDate(date);
@@ -301,7 +289,7 @@ namespace System.Management.Automation
internal static string NonWindowsGetDomainName()
{
if (IsLinux())
if (!IsWindows())
{
string fullyQualifiedName = LinuxPlatform.Native.GetFullyQualifiedName();
if (string.IsNullOrEmpty(fullyQualifiedName))
@@ -326,7 +314,7 @@ namespace System.Management.Automation
internal static string NonWindowsGetUserName()
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.UserName;
}
@@ -338,7 +326,7 @@ namespace System.Management.Automation
internal static string NonWindowsGetMachineName()
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.HostName;
}
@@ -351,7 +339,7 @@ namespace System.Management.Automation
// Hostname in this context seems to be the FQDN
internal static string NonWindowsGetHostName()
{
if (IsLinux())
if (!IsWindows())
{
string hostName = LinuxPlatform.Native.GetFullyQualifiedName();
if (string.IsNullOrEmpty(hostName))
@@ -370,7 +358,7 @@ namespace System.Management.Automation
internal static bool NonWindowsIsExecutable(string path)
{
if (IsLinux())
if (!IsWindows())
{
return LinuxPlatform.IsExecutable(path);
}
@@ -1195,7 +1195,7 @@ namespace Microsoft.PowerShell.Commands
// Porting note: only UTF-8 is supported on Linux, which is not an SBCS
if ((_currentEncoding.Equals(_oemEncoding) ||
_currentEncoding.Equals(_defaultAnsiEncoding))
&& !Platform.IsLinux())
&& Platform.IsWindows())
{
NativeMethods.CPINFO cpInfo;
if (NativeMethods.GetCPInfo((uint)_currentEncoding.CodePage, out cpInfo) &&
@@ -8105,7 +8105,7 @@ namespace Microsoft.PowerShell.Commands
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")]
private static string WinInternalGetLinkType(string filePath)
{
if (Platform.IsLinux())
if (!Platform.IsWindows())
{
throw new Platform.PlatformNotSupportedException();
}