diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs
index 91c6b1a53a..052294ebfa 100644
--- a/BizHawk.Client.Common/PathManager.cs
+++ b/BizHawk.Client.Common/PathManager.cs
@@ -410,7 +410,7 @@ namespace BizHawk.Client.Common
#if true
if (!IsSubfolder(parentPath, absolutePath)) return absolutePath;
- return OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ return OSTailoredCode.IsWindows()
? absolutePath.Replace(parentPath, ".")
: "./" + OSTailoredCode.SimpleSubshell("realpath", $"--relative-to=\"{parentPath}\" \"{absolutePath}\"", $"invalid path {absolutePath} or missing realpath binary");
#else // written for Unix port but may be useful for .NET Core
@@ -441,7 +441,7 @@ namespace BizHawk.Client.Common
/// Algorithm for Windows taken from https://stackoverflow.com/a/7710620/7467292
public static bool IsSubfolder(string parentPath, string childPath)
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
var parentUri = new Uri(parentPath);
diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs
index dcd0654ca4..7f6f2990f1 100644
--- a/BizHawk.Client.Common/config/Config.cs
+++ b/BizHawk.Client.Common/config/Config.cs
@@ -348,7 +348,7 @@ namespace BizHawk.Client.Common
/// warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that.
/// force DX for Windows and GDI+ for Unix when a new config is generated
///
- public EDispMethod DispMethod = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ public EDispMethod DispMethod = OSTailoredCode.IsWindows()
? EDispMethod.SlimDX9
: EDispMethod.GdiPlus;
@@ -378,7 +378,7 @@ namespace BizHawk.Client.Common
public int DispCropBottom = 0;
// Sound options
- public ESoundOutputMethod SoundOutputMethod = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ public ESoundOutputMethod SoundOutputMethod = OSTailoredCode.IsWindows()
? ESoundOutputMethod.DirectSound
: ESoundOutputMethod.OpenAL; // force OpenAL for Unix when config is generated
public bool SoundEnabled = true;
diff --git a/BizHawk.Client.Common/lua/LuaSandbox.cs b/BizHawk.Client.Common/lua/LuaSandbox.cs
index ab1ebdd9e3..e59d41be89 100644
--- a/BizHawk.Client.Common/lua/LuaSandbox.cs
+++ b/BizHawk.Client.Common/lua/LuaSandbox.cs
@@ -43,30 +43,26 @@ namespace BizHawk.Client.Common
return true;
}
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
// WARNING: setting the current directory is SLOW!!! security checks for some reason.
// so we're bypassing it with windows hacks
fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes($"{target}\0")[0])
return SetCurrentDirectoryW(pstr);
}
- else
+
+ if (System.IO.Directory.Exists(_currentDirectory)) // race condition for great justice
{
- if (System.IO.Directory.Exists(_currentDirectory)) // race condition for great justice
- {
- Environment.CurrentDirectory = _currentDirectory; // thats right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY
- return true;
- }
- else
- {
- return false;
- }
+ Environment.CurrentDirectory = _currentDirectory; // that's right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY
+ return true;
}
+
+ return false;
}
private string CoolGetCurrentDirectory()
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
// GUESS WHAT!
// .NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED
@@ -76,10 +72,8 @@ namespace BizHawk.Client.Common
fixed (byte* pBuf = &buf[0])
return System.Text.Encoding.Unicode.GetString(buf, 0, 2 * (int) GetCurrentDirectoryW(32767, pBuf));
}
- else
- {
- return Environment.CurrentDirectory;
- }
+
+ return Environment.CurrentDirectory;
}
private void Sandbox(Action callback, Action exceptionCallback)
diff --git a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs
index 178b086e8e..12bbda19aa 100644
--- a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs
+++ b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs
@@ -86,7 +86,7 @@ namespace BizHawk.Client.EmuHawk
try
{
_ffmpeg = OSTailoredCode.ConstructSubshell(
- OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ OSTailoredCode.IsWindows()
? Path.Combine(PathManager.GetDllDirectory(), "ffmpeg.exe")
: "ffmpeg",
$"-y -f nut -i - {_token.Commandline} \"{_baseName}{(_segment == 0 ? string.Empty : $"_{_segment}")}{_ext}\"",
diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
index 701811e58b..0c2341f1f6 100644
--- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
+++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
@@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
_renderer = new GdiRenderer();
}
diff --git a/BizHawk.Client.EmuHawk/Input/Input.cs b/BizHawk.Client.EmuHawk/Input/Input.cs
index 2066ee5d28..abcc4d0469 100644
--- a/BizHawk.Client.EmuHawk/Input/Input.cs
+++ b/BizHawk.Client.EmuHawk/Input/Input.cs
@@ -128,7 +128,7 @@ namespace BizHawk.Client.EmuHawk
public static void Initialize()
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
KeyInput.Initialize();
IPCKeyInput.Initialize();
@@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
public static void Cleanup()
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
KeyInput.Cleanup();
GamePad.Cleanup();
@@ -339,10 +339,10 @@ namespace BizHawk.Client.EmuHawk
{
while (true)
{
- var keyEvents = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ var keyEvents = OSTailoredCode.IsWindows()
? KeyInput.Update().Concat(IPCKeyInput.Update())
: OTK_Keyboard.Update();
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
GamePad.UpdateAll();
GamePad360.UpdateAll();
diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs
index 79c1f23088..38a4279edc 100644
--- a/BizHawk.Client.EmuHawk/MainForm.Events.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs
@@ -1436,7 +1436,7 @@ namespace BizHawk.Client.EmuHawk
private void RamSearchMenuItem_Click(object sender, EventArgs e)
{
var ramSearch = GlobalWin.Tools.Load();
- if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
+ if (!OSTailoredCode.IsWindows())
{
// this is apparently needed for weird mono-forms-on-different-thread issues
// don't do .Show() within Load() for RamSearch - instead put an instance of it here on MainForm, then show here
diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index 2117cf3411..6103ea01e8 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -165,11 +165,13 @@ namespace BizHawk.Client.EmuHawk
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
// TODO GL - a lot of disorganized wiring-up here
- CGC.CGCBinPath = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ CGC.CGCBinPath = OSTailoredCode.IsWindows()
? Path.Combine(PathManager.GetDllDirectory(), "cgc.exe")
: "cgc"; // installed separately (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH
- PresentationPanel = new PresentationPanel();
- PresentationPanel.GraphicsControl.MainWindow = true;
+ PresentationPanel = new PresentationPanel
+ {
+ GraphicsControl = {MainWindow = true}
+ };
GlobalWin.DisplayManager = new DisplayManager(PresentationPanel);
Controls.Add(PresentationPanel);
Controls.SetChildIndex(PresentationPanel, 0);
@@ -1047,7 +1049,7 @@ namespace BizHawk.Client.EmuHawk
// (this could be determined with more work; other side affects of the fullscreen mode include: corrupted TaskBar, no modal boxes on top of GL control, no screenshots)
// At any rate, we can solve this by adding a 1px black border around the GL control
// Please note: It is important to do this before resizing things, otherwise momentarily a GL control without WS_BORDER will be at the magic dimensions and cause the flakeout
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ if (OSTailoredCode.IsWindows()
&& Global.Config.DispFullscreenHacks
&& Global.Config.DispMethod == Config.EDispMethod.OpenGL)
{
@@ -1076,7 +1078,7 @@ namespace BizHawk.Client.EmuHawk
WindowState = FormWindowState.Normal;
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
// do this even if DispFullscreenHacks aren't enabled, to restore it in case it changed underneath us or something
Padding = new Padding(0);
diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs
index bb5288884f..9d6e077f88 100644
--- a/BizHawk.Client.EmuHawk/Program.cs
+++ b/BizHawk.Client.EmuHawk/Program.cs
@@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
+ if (EXE_PROJECT.OSTailoredCode.IsWindows())
{
var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager;
@@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
private static int Main(string[] args)
{
var exitCode = SubMain(args);
- if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Linux)
+ if (EXE_PROJECT.OSTailoredCode.IsLinux())
{
Console.WriteLine("BizHawk has completed its shutdown routines, killing process...");
Process.GetCurrentProcess().Kill();
@@ -94,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
// and there was a TypeLoadException before the first line of SubMain was reached (some static ColorType init?)
// zero 25-dec-2012 - only do for public builds. its annoying during development
// and don't bother when installed from a package manager i.e. not Windows --yoshi
- if (!VersionInfo.DeveloperBuild && EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
+ if (!VersionInfo.DeveloperBuild && EXE_PROJECT.OSTailoredCode.IsWindows())
{
var thisversion = typeof(Program).Assembly.GetName().Version;
var utilversion = Assembly.Load(new AssemblyName("Bizhawk.Client.Common")).GetName().Version;
@@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.GLManager = GLManager.Instance;
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
- if (EXE_PROJECT.OSTailoredCode.CurrentOS != EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
+ if (!EXE_PROJECT.OSTailoredCode.IsWindows())
Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
REDO_DISPMETHOD:
@@ -193,7 +193,7 @@ REDO_DISPMETHOD:
goto REDO_DISPMETHOD;
}
- if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
+ if (EXE_PROJECT.OSTailoredCode.IsWindows())
{
//WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff.
//The relevant initialization happened just before in "create IGL context".
@@ -314,7 +314,7 @@ REDO_DISPMETHOD:
//so.. we're going to resort to something really bad.
//avert your eyes.
var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");
- if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows // LuaInterface is not currently working on Mono
+ if (EXE_PROJECT.OSTailoredCode.IsWindows() // LuaInterface is not currently working on Mono
&& File.Exists(configPath)
&& (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"UseNLua\": ")) ?? string.Empty)
.Contains("false"))
diff --git a/BizHawk.Client.EmuHawk/ScreenSaver.cs b/BizHawk.Client.EmuHawk/ScreenSaver.cs
index 5b40fe8af3..3d3f6cdaeb 100644
--- a/BizHawk.Client.EmuHawk/ScreenSaver.cs
+++ b/BizHawk.Client.EmuHawk/ScreenSaver.cs
@@ -45,7 +45,7 @@ namespace BizHawk.Client.EmuHawk
public int Duration { get; set; } = 0; //TODO implementation
}
- private static readonly IScreenBlankTimer _screenBlankTimer = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ private static readonly IScreenBlankTimer _screenBlankTimer = OSTailoredCode.IsWindows()
? (IScreenBlankTimer) new Win32ScreenBlankTimer()
: new UnixScreenBlankTimer();
diff --git a/BizHawk.Client.EmuHawk/Sound/Sound.cs b/BizHawk.Client.EmuHawk/Sound/Sound.cs
index 6156b3cfc4..fba982114a 100644
--- a/BizHawk.Client.EmuHawk/Sound/Sound.cs
+++ b/BizHawk.Client.EmuHawk/Sound/Sound.cs
@@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
public Sound(IntPtr mainWindowHandle)
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
_outputDevice = new OpenALSoundOutput(this);
diff --git a/BizHawk.Client.EmuHawk/Throttle.cs b/BizHawk.Client.EmuHawk/Throttle.cs
index d25af833ca..ad29a84557 100644
--- a/BizHawk.Client.EmuHawk/Throttle.cs
+++ b/BizHawk.Client.EmuHawk/Throttle.cs
@@ -160,7 +160,7 @@ namespace BizHawk.Client.EmuHawk
return ms;
}
}
- static PlatformSpecificSysTimer sysTimer = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ static readonly PlatformSpecificSysTimer sysTimer = OSTailoredCode.IsWindows()
? (PlatformSpecificSysTimer) new WinSysTimer()
: new UnixMonoSysTimer();
static uint TimeBeginPeriod(uint ms)
diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs
index 0407f6ccd6..f6bad9b792 100644
--- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs
+++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs
@@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
RefreshAspectRatioOptions();
- if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
+ if (!OSTailoredCode.IsWindows())
{
// Disable SlimDX on Unix
rbD3D9.Enabled = false;
diff --git a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs
index 7a58db21ed..e146d1ea38 100644
--- a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs
@@ -356,15 +356,18 @@ namespace BizHawk.Client.EmuHawk
DoScan();
}
- private void tbbOpenFolder_Click(object sender, EventArgs e)
- {
- var frmWares = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
- if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows && !Directory.Exists(frmWares))
+ private void tbbOpenFolder_Click(object sender, EventArgs e)
+ {
+ var frmWares = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
+ if (!OSTailoredCode.IsWindows() && !Directory.Exists(frmWares))
+ {
Directory.CreateDirectory(frmWares);
- System.Diagnostics.Process.Start(frmWares);
- }
+ }
- private void lvFirmwares_KeyDown(object sender, KeyEventArgs e)
+ System.Diagnostics.Process.Start(frmWares);
+ }
+
+ private void lvFirmwares_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
{
diff --git a/BizHawk.Client.EmuHawk/config/InputWidget.cs b/BizHawk.Client.EmuHawk/config/InputWidget.cs
index 9e4de69f3d..9feb9d632f 100644
--- a/BizHawk.Client.EmuHawk/config/InputWidget.cs
+++ b/BizHawk.Client.EmuHawk/config/InputWidget.cs
@@ -67,7 +67,11 @@ namespace BizHawk.Client.EmuHawk
protected override void OnMouseClick(MouseEventArgs e)
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) HideCaret(Handle);
+ if (OSTailoredCode.IsWindows())
+ {
+ HideCaret(Handle);
+ }
+
base.OnMouseClick(e);
}
@@ -259,7 +263,10 @@ namespace BizHawk.Client.EmuHawk
protected override void OnGotFocus(EventArgs e)
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) HideCaret(Handle);
+ if (OSTailoredCode.IsWindows())
+ {
+ HideCaret(Handle);
+ }
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
diff --git a/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/BizHawk.Client.EmuHawk/config/SoundConfig.cs
index 97faed7762..0c3835b824 100644
--- a/BizHawk.Client.EmuHawk/config/SoundConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/SoundConfig.cs
@@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
cbEnableRWFF.Checked = Global.Config.SoundEnabledRWFF;
cbMuteFrameAdvance.Checked = Global.Config.MuteFrameAdvance;
- if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
+ if (!OSTailoredCode.IsWindows())
{
// Disable DirectSound and XAudio2 on Mono
rbOutputMethodDirectSound.Enabled = false;
@@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk
private void PopulateDeviceList()
{
IEnumerable deviceNames = Enumerable.Empty();
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs
index 9d17fb6518..333d755d19 100644
--- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs
+++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs
@@ -185,7 +185,7 @@ namespace BizHawk.Client.EmuHawk
}
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
- LuaImp = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
+ LuaImp = OSTailoredCode.IsWindows()
? (PlatformEmuLuaLibrary)new EmuLuaLibrary(Emulator.ServiceProvider)
: (PlatformEmuLuaLibrary)new NotReallyLuaLibrary();
if (currentScripts != null)
diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs
index 364d1ead02..11ea327ac2 100644
--- a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs
+++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs
@@ -268,7 +268,7 @@ namespace BizHawk.Client.EmuHawk
/// Algorithm for Windows taken from https://stackoverflow.com/a/485516/7467292
public static string GetRelativePath(string fromPath, string toPath)
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
{
Win32.FileAttributes fromAttr = GetPathAttribute(fromPath);
Win32.FileAttributes toAttr = GetPathAttribute(toPath);
diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs
index c5d78eecc0..a6ab86f44e 100644
--- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs
+++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs
@@ -157,8 +157,7 @@ namespace BizHawk.Client.EmuHawk
}
newTool.Restart();
- if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows
- && newTool is RamSearch)
+ if (!OSTailoredCode.IsWindows() && newTool is RamSearch)
{
// the mono winforms implementation is buggy, skip to the return statement and call Show in MainForm instead
}
@@ -750,7 +749,7 @@ namespace BizHawk.Client.EmuHawk
{
if (!ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool)
|| !lazyAsmTypes.Value.Contains(tool.AssemblyQualifiedName) // not a tool
- || (tool == typeof(LuaConsole) && OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)) // simply doesn't work (for now)
+ || (tool == typeof(LuaConsole) && !OSTailoredCode.IsWindows())) // simply doesn't work (for now)
{
return false;
}
diff --git a/BizHawk.Common/BizInvoke/MemoryBlock.cs b/BizHawk.Common/BizInvoke/MemoryBlock.cs
index b7d938ea11..951f547367 100644
--- a/BizHawk.Common/BizInvoke/MemoryBlock.cs
+++ b/BizHawk.Common/BizInvoke/MemoryBlock.cs
@@ -76,7 +76,7 @@ namespace BizHawk.Common.BizInvoke
///
public MemoryBlock(ulong start, ulong size)
{
- if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
+ if (!OSTailoredCode.IsWindows())
throw new InvalidOperationException("MemoryBlock ctor called on Unix");
if (!WaterboxUtils.Aligned(start))
diff --git a/BizHawk.Common/OSTailoredCode.cs b/BizHawk.Common/OSTailoredCode.cs
index 881b04fac1..b8ad6722ca 100644
--- a/BizHawk.Common/OSTailoredCode.cs
+++ b/BizHawk.Common/OSTailoredCode.cs
@@ -10,11 +10,23 @@ namespace BizHawk.Common
{
public static class OSTailoredCode
{
- /// macOS doesn't use PlatformID.MacOSX
+ ///
+ /// macOS doesn't use PlatformID.MacOSX
+ ///
public static readonly DistinctOS CurrentOS = Environment.OSVersion.Platform == PlatformID.Unix
? SimpleSubshell("uname", "-s", "Can't determine OS") == "Darwin" ? DistinctOS.macOS : DistinctOS.Linux
: DistinctOS.Windows;
+ public static bool IsWindows()
+ {
+ return CurrentOS == DistinctOS.Windows;
+ }
+
+ public static bool IsLinux()
+ {
+ return CurrentOS == DistinctOS.Linux;
+ }
+
private static readonly Lazy _LinkedLibManager = new Lazy(() =>
{
switch (CurrentOS)
@@ -141,13 +153,11 @@ namespace BizHawk.Common
/// OS is implicit and needs to be checked at callsite
public static string SimpleSubshell(string cmd, string args, string noOutputMsg)
{
- using (var proc = ConstructSubshell(cmd, args))
- {
- proc.Start();
- var stdout = proc.StandardOutput;
- if (stdout.EndOfStream) throw new Exception($"{noOutputMsg} ({cmd} wrote nothing to stdout)");
- return stdout.ReadLine();
- }
+ using var proc = ConstructSubshell(cmd, args);
+ proc.Start();
+ var stdout = proc.StandardOutput;
+ if (stdout.EndOfStream) throw new Exception($"{noOutputMsg} ({cmd} wrote nothing to stdout)");
+ return stdout.ReadLine();
}
}
}
diff --git a/BizHawk.Common/TempFileManager.cs b/BizHawk.Common/TempFileManager.cs
index 88d5b628cc..4aa95a9ebd 100644
--- a/BizHawk.Common/TempFileManager.cs
+++ b/BizHawk.Common/TempFileManager.cs
@@ -86,16 +86,21 @@ namespace BizHawk.Common
catch
{
}
+
if(fis != null)
{
foreach (var fi in fis)
{
try
{
- if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
+ if (OSTailoredCode.IsWindows())
+ {
DeleteFileW(fi.FullName); // SHUT. UP. THE. EXCEPTIONS.
+ }
else
+ {
fi.Delete();
+ }
}
catch
{
@@ -107,7 +112,7 @@ namespace BizHawk.Common
}
}
- // try not to slam the filesystem too hard, we dont want this to cause any hiccups
+ // try not to slam the filesystem too hard, we don't want this to cause any hiccups
Thread.Sleep(5000);
}
}
diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings
index 7e2574dd52..efa526d51a 100644
--- a/BizHawk.sln.DotSettings
+++ b/BizHawk.sln.DotSettings
@@ -211,6 +211,7 @@
True
True
True
+ True
True
True
True
@@ -274,6 +275,7 @@
True
True
True
+ True
True
True
True