From d431a4c87f7d27e4f58fc51fcc6738f0af6e38ed Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 29 Sep 2019 21:14:25 -0700 Subject: [PATCH] Fix PS4 autodetect (Fixes #164) --- DICUI.Library/Utilities/Validators.cs | 14 +++++++------- DICUI/Windows/MainWindow.xaml.cs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/DICUI.Library/Utilities/Validators.cs b/DICUI.Library/Utilities/Validators.cs index 2927c70d..22b38516 100644 --- a/DICUI.Library/Utilities/Validators.cs +++ b/DICUI.Library/Utilities/Validators.cs @@ -804,17 +804,17 @@ namespace DICUI.Utilities } /// - /// Get the current system from drive letter + /// Get the current system from drive /// - /// + /// /// - public static KnownSystem? GetKnownSystem(char? driveLetter) + public static KnownSystem? GetKnownSystem(Drive drive) { - // If no letter is provided, then we can't do anything - if (driveLetter == null) + // If drive or drive letter are provided, we can't do anything + if (drive?.Letter == null) return null; - string drivePath = $"{driveLetter}:\\"; + string drivePath = $"{drive.Letter}:\\"; // If we can't read the media in that drive, we can't do anything if (!Directory.Exists(drivePath)) @@ -856,7 +856,7 @@ namespace DICUI.Utilities } // Sony PlayStation 4 - if (File.Exists(Path.Combine(drivePath, "PSLogo.ico"))) + if (drive.VolumeLabel.Equals("PS4VOLUME", StringComparison.OrdinalIgnoreCase)) { return KnownSystem.SonyPlayStation4; } diff --git a/DICUI/Windows/MainWindow.xaml.cs b/DICUI/Windows/MainWindow.xaml.cs index 4493fa3b..f4986852 100644 --- a/DICUI/Windows/MainWindow.xaml.cs +++ b/DICUI/Windows/MainWindow.xaml.cs @@ -341,7 +341,7 @@ namespace DICUI.Windows if (!_options.SkipSystemDetection && index != -1) { ViewModels.LoggerViewModel.VerboseLog("Trying to detect system for drive {0}.. ", _drives[index].Letter); - var currentSystem = Validators.GetKnownSystem(_drives[index].Letter); + var currentSystem = Validators.GetKnownSystem(_drives[index]); ViewModels.LoggerViewModel.VerboseLogLn(currentSystem == null || currentSystem == KnownSystem.NONE ? "unable to detect." : ("detected " + currentSystem.LongName() + ".")); if (currentSystem != null && currentSystem != KnownSystem.NONE)