From 4e013a8d698d775de283ae1b359a0e63c2f2fa3f Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Mon, 27 Nov 2023 20:41:22 -0800 Subject: [PATCH 01/15] figured out how to read the registry for steam games saved in either local machine or current user registry. need to figure out how to find other platforms through the registry then integrate into the main program --- Registry Test/Registry Test.cs | 59 ++++++++++++++++++++++++++++++++++ SunshineGameFinder/Program.cs | 11 +++++-- 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 Registry Test/Registry Test.cs diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs new file mode 100644 index 0000000..51bd02b --- /dev/null +++ b/Registry Test/Registry Test.cs @@ -0,0 +1,59 @@ +// See https://aka.ms/new-console-template for more information + +using Microsoft.Win32; + +internal class Program +{ + private static void Main(string[] args) + { + var registryPaths = new List() + { + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + }; + + var installPaths = new List(); + + if (OperatingSystem.IsWindows()) + { + + foreach (var path in registryPaths) + { + if (path.ToLower().Contains("steam")) + { + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + installPaths.Add(steamRegistry.GetValue("SteamPath").ToString()); + } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + //temp string here to remove drive letter and replace with * + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + installPaths.Add(temp); + } + } + } + + } + + foreach (var path in installPaths) + { + Console.WriteLine(path); + + } + + string MakePathGooder(string path) + { + string temp = string.Concat("*", path.AsSpan(1)); + string gooderPath = temp.Replace("/", @"\"); + + return gooderPath; + } + } + } +} \ No newline at end of file diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index 09045d7..9fa2368 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -11,9 +11,15 @@ const string steamLibraryFolders = @"Program Files (x86)\Steam\steamapps\libraryfolders.vdf"; // default values -var gameDirs = new List() { @"*:\Program Files (x86)\Steam\steamapps\common", @"*:\XboxGames", @"*:\Program Files\EA Games", @"*:\Program Files\Epic Games\", @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" }; +var gameDirs = new List() { + @"*:\Program Files (x86)\Steam\steamapps\common", + @"*:\XboxGames", @"*:\Program Files\EA Games", + @"*:\Program Files\Epic Games\", + @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" +}; var exclusionWords = new List() { "Steam" }; var exeExclusionWords = new List() { "Steam", "Cleanup", "DX", "Uninstall", "Touchup", "redist", "Crash", "Editor" }; +var registryExclusionWords = new List() {/*blah blah blah*/ }; // command setup RootCommand rootCommand = new RootCommand("Searches your computer for various common game install paths for the Sunshine application. After running it, all games that did not already exist will be added to the apps.json, meaning your Moonlight client should see them next time it is started."); @@ -117,7 +123,8 @@ void ScanFolder(string folder) Logger.Log($"Skipping {gameName} as it was an excluded word match..."); continue; } - var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories).FirstOrDefault(exefile => { + var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories) + .FirstOrDefault(exefile => { var exeName = new FileInfo(exefile).Name.ToLower(); return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); }); From 94b2448d126676e954ba72920aa1de20949767a2 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Mon, 27 Nov 2023 20:47:06 -0800 Subject: [PATCH 02/15] figured out how to read the registry for steam gam --- SunshineGameFinder/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index 9fa2368..9e2c3ab 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -1,6 +1,7 @@ // See https://aka.ms/new-console-template for more information using Gameloop.Vdf; using Gameloop.Vdf.Linq; +using Microsoft.Win32; using Newtonsoft.Json; using SunshineGameFinder; using System.CommandLine; @@ -15,7 +16,7 @@ @"*:\Program Files (x86)\Steam\steamapps\common", @"*:\XboxGames", @"*:\Program Files\EA Games", @"*:\Program Files\Epic Games\", - @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" + @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" }; var exclusionWords = new List() { "Steam" }; var exeExclusionWords = new List() { "Steam", "Cleanup", "DX", "Uninstall", "Touchup", "redist", "Crash", "Editor" }; From e6499d74ab09b4d9c0a29076e6cbe4ba03f67b6c Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Tue, 28 Nov 2023 17:10:29 -0800 Subject: [PATCH 03/15] added a way to make the path platform agnostic - fixed some file issues --- Registry Test/Registry Test.cs | 4 ++-- Registry Test/Registry Test.csproj | 15 +++++++++++++++ Registry Test/Registry Test.sln | 25 +++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Registry Test/Registry Test.csproj create mode 100644 Registry Test/Registry Test.sln diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs index 51bd02b..011a207 100644 --- a/Registry Test/Registry Test.cs +++ b/Registry Test/Registry Test.cs @@ -2,7 +2,7 @@ using Microsoft.Win32; -internal class Program +internal partial class Program { private static void Main(string[] args) { @@ -50,7 +50,7 @@ private static void Main(string[] args) string MakePathGooder(string path) { string temp = string.Concat("*", path.AsSpan(1)); - string gooderPath = temp.Replace("/", @"\"); + string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); return gooderPath; } diff --git a/Registry Test/Registry Test.csproj b/Registry Test/Registry Test.csproj new file mode 100644 index 0000000..f572203 --- /dev/null +++ b/Registry Test/Registry Test.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Registry_Test + enable + enable + + + + + + + diff --git a/Registry Test/Registry Test.sln b/Registry Test/Registry Test.sln new file mode 100644 index 0000000..f7c273e --- /dev/null +++ b/Registry Test/Registry Test.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34316.72 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registry Test", "Registry Test.csproj", "{EEC84C97-C986-416A-BDEB-626880AED9B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {44FB9D92-1196-4B13-8ED6-11D05DB89AFA} + EndGlobalSection +EndGlobal From ce2d7e8fc1ef3a119e4a3bdea94122b1ac14f1d5 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Wed, 29 Nov 2023 15:33:52 -0800 Subject: [PATCH 04/15] added functionality to determine OS, then iterate through common install paths for that OS --- .../Platform Agnostic.csproj | 11 ++ .../Platform Agnostic/Platform Agnostic.sln | 25 +++++ .../Platform Agnostic/Program.cs | 100 ++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj create mode 100644 SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln create mode 100644 SunshineGameFinder/Platform Agnostic/Program.cs diff --git a/SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj b/SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj new file mode 100644 index 0000000..bf900e0 --- /dev/null +++ b/SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + Platform_Agnostic + enable + enable + + + diff --git a/SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln b/SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln new file mode 100644 index 0000000..3d7a464 --- /dev/null +++ b/SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34322.80 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform Agnostic", "Platform Agnostic.csproj", "{64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {37A681E6-6313-4B6C-85CB-E2A76E5EC6AA} + EndGlobalSection +EndGlobal diff --git a/SunshineGameFinder/Platform Agnostic/Program.cs b/SunshineGameFinder/Platform Agnostic/Program.cs new file mode 100644 index 0000000..147bd57 --- /dev/null +++ b/SunshineGameFinder/Platform Agnostic/Program.cs @@ -0,0 +1,100 @@ +// See https://aka.ms/new-console-template for more information +// See https://aka.ms/new-console-template for more information + +using Microsoft.Win32; + +internal partial class Program +{ + + private static void Main(string[] args) + { + var installPaths = new List(); + + if (OperatingSystem.IsWindows()) + { + var registryPaths = new List() + { + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + }; + + foreach (var path in registryPaths) + { + if (path.ToLower().Contains("steam")) + { + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + installPaths.Add(steamRegistry.GetValue("SteamPath").ToString()); + } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + //temp string here to remove drive letter and replace with * + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + installPaths.Add(temp); + } + } + } + + } + + foreach (var path in installPaths) + { + Console.WriteLine(path); + + } + + string MakePathGooder(string path) + { + string temp = string.Concat("*", path.AsSpan(1)); + string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); + + return gooderPath; + } + } + else + { + string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + if (OperatingSystem.IsLinux()) + { + var linuxPaths = new List() + { + @"/.local/share/Steam/SteamApps/common", + @"/.local/share/Steam/steamapps/common", + @"/.local/share/Steam/SteamApps/compatdata", + @"/.local/share/Steam/steamapps/compatdata" + }; + + foreach (var path in linuxPaths) + { + string linuxInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(linuxInstallPath)) + { + installPaths.Add(linuxInstallPath); + } + } + + + } + else if (OperatingSystem.IsMacOS()) + { + var macOSPaths = new List() + { + @"/Library/Application Support/Steam/SteamApps/common" + }; + + foreach (var path in macOSPaths) + { + string macInstallPath = string.Concat(userInfo, path); + installPaths.Add(macInstallPath); + } + + } + } + } +} + From ae0cb5112c7df0fe8107df7c0b1a35b92f3c86f3 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Thu, 30 Nov 2023 20:36:53 -0800 Subject: [PATCH 05/15] Attempted to integrate Registry Search and make it platform agnostic. Was unable to test it and code got a bit hadouken-y so will definitely need input from someone with Moonlight/Sunshine to test and with more experience coding to optimize/clean up a bit --- Registry Test/Registry Test.cs | 75 ++++++++++++++---- SunshineGameFinder/Program.cs | 136 +++++++++++++++++++++++++++++---- 2 files changed, 179 insertions(+), 32 deletions(-) diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs index 011a207..f1e43a6 100644 --- a/Registry Test/Registry Test.cs +++ b/Registry Test/Registry Test.cs @@ -1,21 +1,19 @@ -// See https://aka.ms/new-console-template for more information - -using Microsoft.Win32; +using Microsoft.Win32; internal partial class Program { + private static void Main(string[] args) { - var registryPaths = new List() - { - @"SOFTWARE\Wow6432Node\Valve\Steam", - @"SOFTWARE\Valve\Steam" - }; - var installPaths = new List(); if (OperatingSystem.IsWindows()) { + var registryPaths = new List() + { + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + }; foreach (var path in registryPaths) { @@ -24,7 +22,9 @@ private static void Main(string[] args) RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) { - installPaths.Add(steamRegistry.GetValue("SteamPath").ToString()); + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + installPaths.Add(temp); } else { @@ -41,19 +41,62 @@ private static void Main(string[] args) } - foreach (var path in installPaths) - { - Console.WriteLine(path); - - } string MakePathGooder(string path) { - string temp = string.Concat("*", path.AsSpan(1)); + string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); return gooderPath; } } + else + { + string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + if (OperatingSystem.IsLinux()) + { + var linuxPaths = new List() + { + @"/.local/share/Steam/SteamApps/common", + @"/.local/share/Steam/steamapps/common", + @"/.local/share/Steam/SteamApps/compatdata", + @"/.local/share/Steam/steamapps/compatdata" + }; + + foreach (var path in linuxPaths) + { + string linuxInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(linuxInstallPath)) + { + installPaths.Add(linuxInstallPath); + } + } + + + } + else if (OperatingSystem.IsMacOS()) + { + var macOSPaths = new List() + { + @"/Library/Application Support/Steam/SteamApps/common" + }; + + foreach (var path in macOSPaths) + { + string macInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(macInstallPath)) + { + installPaths.Add(macInstallPath); + } + } + } + } + + foreach (var path in installPaths) + { + Console.WriteLine(path); + + } + } } \ No newline at end of file diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index 9e2c3ab..90b119e 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -13,14 +13,21 @@ // default values var gameDirs = new List() { - @"*:\Program Files (x86)\Steam\steamapps\common", - @"*:\XboxGames", @"*:\Program Files\EA Games", - @"*:\Program Files\Epic Games\", - @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" + //@"*:\Program Files (x86)\Steam\steamapps\common", + //@"*:\XboxGames", @"*:\Program Files\EA Games", + //@"*:\Program Files\Epic Games\", + //@"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" }; + +var registryDir = new List() +{ + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + //Other installer registry paths... +}; + var exclusionWords = new List() { "Steam" }; var exeExclusionWords = new List() { "Steam", "Cleanup", "DX", "Uninstall", "Touchup", "redist", "Crash", "Editor" }; -var registryExclusionWords = new List() {/*blah blah blah*/ }; // command setup RootCommand rootCommand = new RootCommand("Searches your computer for various common game install paths for the Sunshine application. After running it, all games that did not already exist will be added to the apps.json, meaning your Moonlight client should see them next time it is started."); @@ -182,25 +189,122 @@ void ScanFolder(string folder) Console.WriteLine(""); //blank line to separate platforms } + string MakePathGooder(string path) + { + string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; + string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); + + return gooderPath; + } + var logicalDrives = DriveInfo.GetDrives(); var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); - foreach (var drive in logicalDrives) + if (OperatingSystem.IsWindows()) { - var libraryFoldersPath = drive.Name + steamLibraryFolders; - var file = new FileInfo(libraryFoldersPath); - if (!file.Exists) + gameDirs = new List { - Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); - continue; - } - var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); - foreach(var library in libraries.Value) + @"*:\Program Files (x86)\Steam\steamapps\common", + @"*:\XboxGames", + @"*:\Program Files\EA Games", + @"*:\Program Files\Epic Games\", + @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" + //Other common directories + }; + + bool isLibraryFound = false; + foreach (var drive in logicalDrives) { - if (library is not VProperty libProp) + var libraryFoldersPath = drive.Name + steamLibraryFolders; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) + { + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); continue; + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) + continue; + + gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); + isLibraryFound = true; + } + } + if (!isLibraryFound) + { + foreach (var path in registryDir) + { + if (path.ToLower().Contains("steam")) + { + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + gameDirs.Add(temp); + } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + gameDirs.Add(temp); + } + } + } + /*else if (path contains other installer keywords) + { + + }*/ + } + } + } + else + { + string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + if (OperatingSystem.IsLinux()) + { + var linuxPaths = new List() + { + //Conflicting data on whether it's SteamApps or steamapps so here's both + @"/.local/share/Steam/SteamApps/common", + @"/.local/share/Steam/steamapps/common", + @"/.local/share/Steam/SteamApps/compatdata", + @"/.local/share/Steam/steamapps/compatdata" + //Other common directories (rockstar, epic, etc) + }; + + foreach (var path in linuxPaths) + { + string linuxInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(linuxInstallPath)) + { + gameDirs.Add(linuxInstallPath); + } + } + - gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); + } + else if (OperatingSystem.IsMacOS()) + { + var macOSPaths = new List() + { + @"/Library/Application Support/Steam/SteamApps/common" + //Other common directories (rockstar, epic, etc) + }; + + foreach (var path in macOSPaths) + { + string macInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(macInstallPath)) + { + gameDirs.Add(macInstallPath); + } + } } } From 57d1dd2b9d10b812cecbd79c5857ab9e1fadb18a Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Thu, 30 Nov 2023 21:00:30 -0800 Subject: [PATCH 06/15] Turned the registry search into a function to make future expansion/implementation a bit easier, which also helped with the hadouken --- Registry Test/Registry Test.cs | 20 ++++++---- SunshineGameFinder/Program.cs | 69 ++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs index f1e43a6..620d6b2 100644 --- a/Registry Test/Registry Test.cs +++ b/Registry Test/Registry Test.cs @@ -31,7 +31,6 @@ private static void Main(string[] args) steamRegistry = Registry.CurrentUser.OpenSubKey(path); if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) { - //temp string here to remove drive letter and replace with * string temp = steamRegistry.GetValue("SteamPath").ToString(); temp = MakePathGooder(temp); installPaths.Add(temp); @@ -42,13 +41,7 @@ private static void Main(string[] args) } - string MakePathGooder(string path) - { - string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; - string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); - - return gooderPath; - } + } else { @@ -57,10 +50,12 @@ string MakePathGooder(string path) { var linuxPaths = new List() { + //Conflicting data on whether it's SteamApps or steamapps so here's both @"/.local/share/Steam/SteamApps/common", @"/.local/share/Steam/steamapps/common", @"/.local/share/Steam/SteamApps/compatdata", @"/.local/share/Steam/steamapps/compatdata" + //Other common directories (rockstar, epic, etc) }; foreach (var path in linuxPaths) @@ -79,6 +74,7 @@ string MakePathGooder(string path) var macOSPaths = new List() { @"/Library/Application Support/Steam/SteamApps/common" + //Other common directories (rockstar, epic, etc) }; foreach (var path in macOSPaths) @@ -98,5 +94,13 @@ string MakePathGooder(string path) } + string MakePathGooder(string path) + { + string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; + string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); + + return gooderPath; + } + } } \ No newline at end of file diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index 90b119e..f8acbe7 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -131,8 +131,8 @@ void ScanFolder(string folder) Logger.Log($"Skipping {gameName} as it was an excluded word match..."); continue; } - var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories) - .FirstOrDefault(exefile => { + var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories).FirstOrDefault(exefile => + { var exeName = new FileInfo(exefile).Name.ToLower(); return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); }); @@ -197,6 +197,37 @@ string MakePathGooder(string path) return gooderPath; } + void RegistrySearch() + { + foreach (var path in registryDir) + { + if (path.ToLower().Contains("steam")) + { + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + gameDirs.Add(temp); + } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + gameDirs.Add(temp); + } + } + } + /*else if (path contains other installer keywords) + { + + }*/ + } + } + var logicalDrives = DriveInfo.GetDrives(); var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); @@ -212,7 +243,7 @@ string MakePathGooder(string path) //Other common directories }; - bool isLibraryFound = false; + bool isSteamLibraryFound = false; foreach (var drive in logicalDrives) { var libraryFoldersPath = drive.Name + steamLibraryFolders; @@ -229,38 +260,12 @@ string MakePathGooder(string path) continue; gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); - isLibraryFound = true; + isSteamLibraryFound = true; } } - if (!isLibraryFound) + if (!isSteamLibraryFound) { - foreach (var path in registryDir) - { - if (path.ToLower().Contains("steam")) - { - RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - gameDirs.Add(temp); - } - else - { - steamRegistry = Registry.CurrentUser.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - gameDirs.Add(temp); - } - } - } - /*else if (path contains other installer keywords) - { - - }*/ - } + RegistrySearch(); } } else From 84f0d2f1f21556903998c76d4de421781e0d7262 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Thu, 30 Nov 2023 21:20:16 -0800 Subject: [PATCH 07/15] added checking for libraries on linux/macOS - might also turn that into a function but it's late and i'm going to bed --- SunshineGameFinder/Program.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index f8acbe7..7a69846 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -283,6 +283,20 @@ void RegistrySearch() //Other common directories (rockstar, epic, etc) }; + var libraryFoldersPath = userInfo + @"/.local/share/Steam/steamapps/libraryfolders"; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) + { + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) + continue; + + gameDirs.Add($@"{libProp.Value.Value("path")}/steamapps/common"); + } foreach (var path in linuxPaths) { string linuxInstallPath = string.Concat(userInfo, path); @@ -301,7 +315,20 @@ void RegistrySearch() @"/Library/Application Support/Steam/SteamApps/common" //Other common directories (rockstar, epic, etc) }; + var libraryFoldersPath = userInfo + @"/Library/Application Support/Steam/SteamApps/libraryfolders"; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) + { + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) + continue; + gameDirs.Add($@"{libProp.Value.Value("path")}/steamapps/common"); + } foreach (var path in macOSPaths) { string macInstallPath = string.Concat(userInfo, path); From 6ebf9ab79b3dac34180beea4d100a0c8a7999b54 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Fri, 1 Dec 2023 10:48:53 -0800 Subject: [PATCH 08/15] no idea how to use this shit --- .../FileWriter.cs => FileWriter.cs | 0 .../ImageScraper.cs => ImageScraper.cs | 0 SunshineGameFinder/Logger.cs => Logger.cs | 0 SunshineGameFinder/Program.cs => Program.cs | 170 ++++++++++++++++-- .../launchSettings.json | 0 Registry Test/Registry Test.cs | 106 +++++++++++ Registry Test/Registry Test.csproj | 15 ++ Registry Test/Registry Test.sln | 25 +++ ...hineAppsConfig.cs => SunshineAppsConfig.cs | 0 ...Finder.csproj => SunshineGameFinder.csproj | 0 ...neGameFinder.sln => SunshineGameFinder.sln | 0 .../PublishProfiles/ClickOnceProfile.pubxml | 35 ---- 12 files changed, 303 insertions(+), 48 deletions(-) rename SunshineGameFinder/FileWriter.cs => FileWriter.cs (100%) rename SunshineGameFinder/ImageScraper.cs => ImageScraper.cs (100%) rename SunshineGameFinder/Logger.cs => Logger.cs (100%) rename SunshineGameFinder/Program.cs => Program.cs (60%) rename {SunshineGameFinder/Properties => Properties}/launchSettings.json (100%) create mode 100644 Registry Test/Registry Test.cs create mode 100644 Registry Test/Registry Test.csproj create mode 100644 Registry Test/Registry Test.sln rename SunshineGameFinder/SunshineAppsConfig.cs => SunshineAppsConfig.cs (100%) rename SunshineGameFinder/SunshineGameFinder.csproj => SunshineGameFinder.csproj (100%) rename SunshineGameFinder/SunshineGameFinder.sln => SunshineGameFinder.sln (100%) delete mode 100644 SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml diff --git a/SunshineGameFinder/FileWriter.cs b/FileWriter.cs similarity index 100% rename from SunshineGameFinder/FileWriter.cs rename to FileWriter.cs diff --git a/SunshineGameFinder/ImageScraper.cs b/ImageScraper.cs similarity index 100% rename from SunshineGameFinder/ImageScraper.cs rename to ImageScraper.cs diff --git a/SunshineGameFinder/Logger.cs b/Logger.cs similarity index 100% rename from SunshineGameFinder/Logger.cs rename to Logger.cs diff --git a/SunshineGameFinder/Program.cs b/Program.cs similarity index 60% rename from SunshineGameFinder/Program.cs rename to Program.cs index 09045d7..7a69846 100644 --- a/SunshineGameFinder/Program.cs +++ b/Program.cs @@ -1,6 +1,7 @@ // See https://aka.ms/new-console-template for more information using Gameloop.Vdf; using Gameloop.Vdf.Linq; +using Microsoft.Win32; using Newtonsoft.Json; using SunshineGameFinder; using System.CommandLine; @@ -11,7 +12,20 @@ const string steamLibraryFolders = @"Program Files (x86)\Steam\steamapps\libraryfolders.vdf"; // default values -var gameDirs = new List() { @"*:\Program Files (x86)\Steam\steamapps\common", @"*:\XboxGames", @"*:\Program Files\EA Games", @"*:\Program Files\Epic Games\", @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" }; +var gameDirs = new List() { + //@"*:\Program Files (x86)\Steam\steamapps\common", + //@"*:\XboxGames", @"*:\Program Files\EA Games", + //@"*:\Program Files\Epic Games\", + //@"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" +}; + +var registryDir = new List() +{ + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + //Other installer registry paths... +}; + var exclusionWords = new List() { "Steam" }; var exeExclusionWords = new List() { "Steam", "Cleanup", "DX", "Uninstall", "Touchup", "redist", "Crash", "Editor" }; @@ -117,7 +131,8 @@ void ScanFolder(string folder) Logger.Log($"Skipping {gameName} as it was an excluded word match..."); continue; } - var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories).FirstOrDefault(exefile => { + var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories).FirstOrDefault(exefile => + { var exeName = new FileInfo(exefile).Name.ToLower(); return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); }); @@ -174,25 +189,154 @@ void ScanFolder(string folder) Console.WriteLine(""); //blank line to separate platforms } + string MakePathGooder(string path) + { + string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; + string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); + + return gooderPath; + } + + void RegistrySearch() + { + foreach (var path in registryDir) + { + if (path.ToLower().Contains("steam")) + { + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + gameDirs.Add(temp); + } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + gameDirs.Add(temp); + } + } + } + /*else if (path contains other installer keywords) + { + + }*/ + } + } + var logicalDrives = DriveInfo.GetDrives(); var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); - foreach (var drive in logicalDrives) + if (OperatingSystem.IsWindows()) { - var libraryFoldersPath = drive.Name + steamLibraryFolders; - var file = new FileInfo(libraryFoldersPath); - if (!file.Exists) + gameDirs = new List { - Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); - continue; - } - var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); - foreach(var library in libraries.Value) + @"*:\Program Files (x86)\Steam\steamapps\common", + @"*:\XboxGames", + @"*:\Program Files\EA Games", + @"*:\Program Files\Epic Games\", + @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" + //Other common directories + }; + + bool isSteamLibraryFound = false; + foreach (var drive in logicalDrives) { - if (library is not VProperty libProp) + var libraryFoldersPath = drive.Name + steamLibraryFolders; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) + { + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); continue; + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) + continue; + + gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); + isSteamLibraryFound = true; + } + } + if (!isSteamLibraryFound) + { + RegistrySearch(); + } + } + else + { + string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + if (OperatingSystem.IsLinux()) + { + var linuxPaths = new List() + { + //Conflicting data on whether it's SteamApps or steamapps so here's both + @"/.local/share/Steam/SteamApps/common", + @"/.local/share/Steam/steamapps/common", + @"/.local/share/Steam/SteamApps/compatdata", + @"/.local/share/Steam/steamapps/compatdata" + //Other common directories (rockstar, epic, etc) + }; + + var libraryFoldersPath = userInfo + @"/.local/share/Steam/steamapps/libraryfolders"; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) + { + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) + continue; + + gameDirs.Add($@"{libProp.Value.Value("path")}/steamapps/common"); + } + foreach (var path in linuxPaths) + { + string linuxInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(linuxInstallPath)) + { + gameDirs.Add(linuxInstallPath); + } + } - gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); + + } + else if (OperatingSystem.IsMacOS()) + { + var macOSPaths = new List() + { + @"/Library/Application Support/Steam/SteamApps/common" + //Other common directories (rockstar, epic, etc) + }; + var libraryFoldersPath = userInfo + @"/Library/Application Support/Steam/SteamApps/libraryfolders"; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) + { + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) + continue; + + gameDirs.Add($@"{libProp.Value.Value("path")}/steamapps/common"); + } + foreach (var path in macOSPaths) + { + string macInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(macInstallPath)) + { + gameDirs.Add(macInstallPath); + } + } } } diff --git a/SunshineGameFinder/Properties/launchSettings.json b/Properties/launchSettings.json similarity index 100% rename from SunshineGameFinder/Properties/launchSettings.json rename to Properties/launchSettings.json diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs new file mode 100644 index 0000000..620d6b2 --- /dev/null +++ b/Registry Test/Registry Test.cs @@ -0,0 +1,106 @@ +using Microsoft.Win32; + +internal partial class Program +{ + + private static void Main(string[] args) + { + var installPaths = new List(); + + if (OperatingSystem.IsWindows()) + { + var registryPaths = new List() + { + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + }; + + foreach (var path in registryPaths) + { + if (path.ToLower().Contains("steam")) + { + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + installPaths.Add(temp); + } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = MakePathGooder(temp); + installPaths.Add(temp); + } + } + } + + } + + + + } + else + { + string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + if (OperatingSystem.IsLinux()) + { + var linuxPaths = new List() + { + //Conflicting data on whether it's SteamApps or steamapps so here's both + @"/.local/share/Steam/SteamApps/common", + @"/.local/share/Steam/steamapps/common", + @"/.local/share/Steam/SteamApps/compatdata", + @"/.local/share/Steam/steamapps/compatdata" + //Other common directories (rockstar, epic, etc) + }; + + foreach (var path in linuxPaths) + { + string linuxInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(linuxInstallPath)) + { + installPaths.Add(linuxInstallPath); + } + } + + + } + else if (OperatingSystem.IsMacOS()) + { + var macOSPaths = new List() + { + @"/Library/Application Support/Steam/SteamApps/common" + //Other common directories (rockstar, epic, etc) + }; + + foreach (var path in macOSPaths) + { + string macInstallPath = string.Concat(userInfo, path); + if (Directory.Exists(macInstallPath)) + { + installPaths.Add(macInstallPath); + } + } + } + } + + foreach (var path in installPaths) + { + Console.WriteLine(path); + + } + + string MakePathGooder(string path) + { + string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; + string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); + + return gooderPath; + } + + } +} \ No newline at end of file diff --git a/Registry Test/Registry Test.csproj b/Registry Test/Registry Test.csproj new file mode 100644 index 0000000..f572203 --- /dev/null +++ b/Registry Test/Registry Test.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Registry_Test + enable + enable + + + + + + + diff --git a/Registry Test/Registry Test.sln b/Registry Test/Registry Test.sln new file mode 100644 index 0000000..f7c273e --- /dev/null +++ b/Registry Test/Registry Test.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34316.72 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registry Test", "Registry Test.csproj", "{EEC84C97-C986-416A-BDEB-626880AED9B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {44FB9D92-1196-4B13-8ED6-11D05DB89AFA} + EndGlobalSection +EndGlobal diff --git a/SunshineGameFinder/SunshineAppsConfig.cs b/SunshineAppsConfig.cs similarity index 100% rename from SunshineGameFinder/SunshineAppsConfig.cs rename to SunshineAppsConfig.cs diff --git a/SunshineGameFinder/SunshineGameFinder.csproj b/SunshineGameFinder.csproj similarity index 100% rename from SunshineGameFinder/SunshineGameFinder.csproj rename to SunshineGameFinder.csproj diff --git a/SunshineGameFinder/SunshineGameFinder.sln b/SunshineGameFinder.sln similarity index 100% rename from SunshineGameFinder/SunshineGameFinder.sln rename to SunshineGameFinder.sln diff --git a/SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml b/SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml deleted file mode 100644 index a5f0b02..0000000 --- a/SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - 1 - 1.6.0.* - True - Release - False - true - True - Disk - True - False - True - False - Any CPU - bin\publish\ - bin\publish\ - ClickOnce - False - True - win-x64 - True - (none) - False - net6.0 - False - Foreground - False - Publish.html - - \ No newline at end of file From 53c95d05a044a888a3609143c62c80fb4dcd5f94 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Fri, 1 Dec 2023 11:20:08 -0800 Subject: [PATCH 09/15] added sorting by file size to accommodate rockstar (and likely other) launchers that have a .exe of the same name in the steamapps/common folder that just launches the launcher - now it should find the larger of the two .exes first (the actual game launcher) --- Program.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Program.cs b/Program.cs index 7a69846..6b8419e 100644 --- a/Program.cs +++ b/Program.cs @@ -21,8 +21,8 @@ var registryDir = new List() { - @"SOFTWARE\Wow6432Node\Valve\Steam", - @"SOFTWARE\Valve\Steam" + //@"SOFTWARE\Wow6432Node\Valve\Steam", + //@"SOFTWARE\Valve\Steam" //Other installer registry paths... }; @@ -131,7 +131,9 @@ void ScanFolder(string folder) Logger.Log($"Skipping {gameName} as it was an excluded word match..."); continue; } - var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories).FirstOrDefault(exefile => + var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories) + .OrderBy(f => new FileInfo(f).Length) + .FirstOrDefault(exefile => { var exeName = new FileInfo(exefile).Name.ToLower(); return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); @@ -265,6 +267,11 @@ void RegistrySearch() } if (!isSteamLibraryFound) { + registryDir = new List + { + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + }; RegistrySearch(); } } From 831bee54496eca6abdf9b55537a8e2b38bfea740 Mon Sep 17 00:00:00 2001 From: Mike J <151983178+mikednjoy@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:25:57 -0800 Subject: [PATCH 10/15] Delete Registry Test directory removed testing grounds for registry search now that the functionality is implemented into the main program --- Registry Test/Registry Test.cs | 106 ----------------------------- Registry Test/Registry Test.csproj | 15 ---- Registry Test/Registry Test.sln | 25 ------- 3 files changed, 146 deletions(-) delete mode 100644 Registry Test/Registry Test.cs delete mode 100644 Registry Test/Registry Test.csproj delete mode 100644 Registry Test/Registry Test.sln diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs deleted file mode 100644 index 620d6b2..0000000 --- a/Registry Test/Registry Test.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Microsoft.Win32; - -internal partial class Program -{ - - private static void Main(string[] args) - { - var installPaths = new List(); - - if (OperatingSystem.IsWindows()) - { - var registryPaths = new List() - { - @"SOFTWARE\Wow6432Node\Valve\Steam", - @"SOFTWARE\Valve\Steam" - }; - - foreach (var path in registryPaths) - { - if (path.ToLower().Contains("steam")) - { - RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - installPaths.Add(temp); - } - else - { - steamRegistry = Registry.CurrentUser.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - installPaths.Add(temp); - } - } - } - - } - - - - } - else - { - string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - if (OperatingSystem.IsLinux()) - { - var linuxPaths = new List() - { - //Conflicting data on whether it's SteamApps or steamapps so here's both - @"/.local/share/Steam/SteamApps/common", - @"/.local/share/Steam/steamapps/common", - @"/.local/share/Steam/SteamApps/compatdata", - @"/.local/share/Steam/steamapps/compatdata" - //Other common directories (rockstar, epic, etc) - }; - - foreach (var path in linuxPaths) - { - string linuxInstallPath = string.Concat(userInfo, path); - if (Directory.Exists(linuxInstallPath)) - { - installPaths.Add(linuxInstallPath); - } - } - - - } - else if (OperatingSystem.IsMacOS()) - { - var macOSPaths = new List() - { - @"/Library/Application Support/Steam/SteamApps/common" - //Other common directories (rockstar, epic, etc) - }; - - foreach (var path in macOSPaths) - { - string macInstallPath = string.Concat(userInfo, path); - if (Directory.Exists(macInstallPath)) - { - installPaths.Add(macInstallPath); - } - } - } - } - - foreach (var path in installPaths) - { - Console.WriteLine(path); - - } - - string MakePathGooder(string path) - { - string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; - string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); - - return gooderPath; - } - - } -} \ No newline at end of file diff --git a/Registry Test/Registry Test.csproj b/Registry Test/Registry Test.csproj deleted file mode 100644 index f572203..0000000 --- a/Registry Test/Registry Test.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Exe - net8.0 - Registry_Test - enable - enable - - - - - - - diff --git a/Registry Test/Registry Test.sln b/Registry Test/Registry Test.sln deleted file mode 100644 index f7c273e..0000000 --- a/Registry Test/Registry Test.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34316.72 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registry Test", "Registry Test.csproj", "{EEC84C97-C986-416A-BDEB-626880AED9B1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {44FB9D92-1196-4B13-8ED6-11D05DB89AFA} - EndGlobalSection -EndGlobal From 2dc6b711e315cb392c9a10ee9ef201c6c0ab522d Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Fri, 1 Dec 2023 11:31:46 -0800 Subject: [PATCH 11/15] cleaned up files - not sure how they got so fucked. learning git is hard --- Registry Test/Registry Test.cs | 106 ------------------ Registry Test/Registry Test.csproj | 15 --- Registry Test/Registry Test.sln | 25 ----- .../Platform Agnostic.csproj | 11 -- .../Platform Agnostic/Platform Agnostic.sln | 25 ----- .../Platform Agnostic/Program.cs | 100 ----------------- 6 files changed, 282 deletions(-) delete mode 100644 Registry Test/Registry Test.cs delete mode 100644 Registry Test/Registry Test.csproj delete mode 100644 Registry Test/Registry Test.sln delete mode 100644 SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj delete mode 100644 SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln delete mode 100644 SunshineGameFinder/Platform Agnostic/Program.cs diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs deleted file mode 100644 index 620d6b2..0000000 --- a/Registry Test/Registry Test.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Microsoft.Win32; - -internal partial class Program -{ - - private static void Main(string[] args) - { - var installPaths = new List(); - - if (OperatingSystem.IsWindows()) - { - var registryPaths = new List() - { - @"SOFTWARE\Wow6432Node\Valve\Steam", - @"SOFTWARE\Valve\Steam" - }; - - foreach (var path in registryPaths) - { - if (path.ToLower().Contains("steam")) - { - RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - installPaths.Add(temp); - } - else - { - steamRegistry = Registry.CurrentUser.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - installPaths.Add(temp); - } - } - } - - } - - - - } - else - { - string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - if (OperatingSystem.IsLinux()) - { - var linuxPaths = new List() - { - //Conflicting data on whether it's SteamApps or steamapps so here's both - @"/.local/share/Steam/SteamApps/common", - @"/.local/share/Steam/steamapps/common", - @"/.local/share/Steam/SteamApps/compatdata", - @"/.local/share/Steam/steamapps/compatdata" - //Other common directories (rockstar, epic, etc) - }; - - foreach (var path in linuxPaths) - { - string linuxInstallPath = string.Concat(userInfo, path); - if (Directory.Exists(linuxInstallPath)) - { - installPaths.Add(linuxInstallPath); - } - } - - - } - else if (OperatingSystem.IsMacOS()) - { - var macOSPaths = new List() - { - @"/Library/Application Support/Steam/SteamApps/common" - //Other common directories (rockstar, epic, etc) - }; - - foreach (var path in macOSPaths) - { - string macInstallPath = string.Concat(userInfo, path); - if (Directory.Exists(macInstallPath)) - { - installPaths.Add(macInstallPath); - } - } - } - } - - foreach (var path in installPaths) - { - Console.WriteLine(path); - - } - - string MakePathGooder(string path) - { - string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; - string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); - - return gooderPath; - } - - } -} \ No newline at end of file diff --git a/Registry Test/Registry Test.csproj b/Registry Test/Registry Test.csproj deleted file mode 100644 index f572203..0000000 --- a/Registry Test/Registry Test.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Exe - net8.0 - Registry_Test - enable - enable - - - - - - - diff --git a/Registry Test/Registry Test.sln b/Registry Test/Registry Test.sln deleted file mode 100644 index f7c273e..0000000 --- a/Registry Test/Registry Test.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34316.72 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registry Test", "Registry Test.csproj", "{EEC84C97-C986-416A-BDEB-626880AED9B1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {44FB9D92-1196-4B13-8ED6-11D05DB89AFA} - EndGlobalSection -EndGlobal diff --git a/SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj b/SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj deleted file mode 100644 index bf900e0..0000000 --- a/SunshineGameFinder/Platform Agnostic/Platform Agnostic.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net8.0 - Platform_Agnostic - enable - enable - - - diff --git a/SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln b/SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln deleted file mode 100644 index 3d7a464..0000000 --- a/SunshineGameFinder/Platform Agnostic/Platform Agnostic.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34322.80 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform Agnostic", "Platform Agnostic.csproj", "{64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {64B07EED-1BF1-4CAD-A41A-ACD2C25A5DAF}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {37A681E6-6313-4B6C-85CB-E2A76E5EC6AA} - EndGlobalSection -EndGlobal diff --git a/SunshineGameFinder/Platform Agnostic/Program.cs b/SunshineGameFinder/Platform Agnostic/Program.cs deleted file mode 100644 index 147bd57..0000000 --- a/SunshineGameFinder/Platform Agnostic/Program.cs +++ /dev/null @@ -1,100 +0,0 @@ -// See https://aka.ms/new-console-template for more information -// See https://aka.ms/new-console-template for more information - -using Microsoft.Win32; - -internal partial class Program -{ - - private static void Main(string[] args) - { - var installPaths = new List(); - - if (OperatingSystem.IsWindows()) - { - var registryPaths = new List() - { - @"SOFTWARE\Wow6432Node\Valve\Steam", - @"SOFTWARE\Valve\Steam" - }; - - foreach (var path in registryPaths) - { - if (path.ToLower().Contains("steam")) - { - RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - installPaths.Add(steamRegistry.GetValue("SteamPath").ToString()); - } - else - { - steamRegistry = Registry.CurrentUser.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - //temp string here to remove drive letter and replace with * - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - installPaths.Add(temp); - } - } - } - - } - - foreach (var path in installPaths) - { - Console.WriteLine(path); - - } - - string MakePathGooder(string path) - { - string temp = string.Concat("*", path.AsSpan(1)); - string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); - - return gooderPath; - } - } - else - { - string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - if (OperatingSystem.IsLinux()) - { - var linuxPaths = new List() - { - @"/.local/share/Steam/SteamApps/common", - @"/.local/share/Steam/steamapps/common", - @"/.local/share/Steam/SteamApps/compatdata", - @"/.local/share/Steam/steamapps/compatdata" - }; - - foreach (var path in linuxPaths) - { - string linuxInstallPath = string.Concat(userInfo, path); - if (Directory.Exists(linuxInstallPath)) - { - installPaths.Add(linuxInstallPath); - } - } - - - } - else if (OperatingSystem.IsMacOS()) - { - var macOSPaths = new List() - { - @"/Library/Application Support/Steam/SteamApps/common" - }; - - foreach (var path in macOSPaths) - { - string macInstallPath = string.Concat(userInfo, path); - installPaths.Add(macInstallPath); - } - - } - } - } -} - From 419307db94ec0f84db685363b71261721c765c5f Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Fri, 1 Dec 2023 16:48:18 -0800 Subject: [PATCH 12/15] implementing fixes from draft push --- Registry Test/Registry Test.cs | 106 ---------- Registry Test/Registry Test.csproj | 15 -- Registry Test/Registry Test.sln | 25 --- SunshineGameFinder/Program.cs | 298 ++++++++++++++--------------- 4 files changed, 143 insertions(+), 301 deletions(-) delete mode 100644 Registry Test/Registry Test.cs delete mode 100644 Registry Test/Registry Test.csproj delete mode 100644 Registry Test/Registry Test.sln diff --git a/Registry Test/Registry Test.cs b/Registry Test/Registry Test.cs deleted file mode 100644 index 620d6b2..0000000 --- a/Registry Test/Registry Test.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Microsoft.Win32; - -internal partial class Program -{ - - private static void Main(string[] args) - { - var installPaths = new List(); - - if (OperatingSystem.IsWindows()) - { - var registryPaths = new List() - { - @"SOFTWARE\Wow6432Node\Valve\Steam", - @"SOFTWARE\Valve\Steam" - }; - - foreach (var path in registryPaths) - { - if (path.ToLower().Contains("steam")) - { - RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - installPaths.Add(temp); - } - else - { - steamRegistry = Registry.CurrentUser.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - installPaths.Add(temp); - } - } - } - - } - - - - } - else - { - string userInfo = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - if (OperatingSystem.IsLinux()) - { - var linuxPaths = new List() - { - //Conflicting data on whether it's SteamApps or steamapps so here's both - @"/.local/share/Steam/SteamApps/common", - @"/.local/share/Steam/steamapps/common", - @"/.local/share/Steam/SteamApps/compatdata", - @"/.local/share/Steam/steamapps/compatdata" - //Other common directories (rockstar, epic, etc) - }; - - foreach (var path in linuxPaths) - { - string linuxInstallPath = string.Concat(userInfo, path); - if (Directory.Exists(linuxInstallPath)) - { - installPaths.Add(linuxInstallPath); - } - } - - - } - else if (OperatingSystem.IsMacOS()) - { - var macOSPaths = new List() - { - @"/Library/Application Support/Steam/SteamApps/common" - //Other common directories (rockstar, epic, etc) - }; - - foreach (var path in macOSPaths) - { - string macInstallPath = string.Concat(userInfo, path); - if (Directory.Exists(macInstallPath)) - { - installPaths.Add(macInstallPath); - } - } - } - } - - foreach (var path in installPaths) - { - Console.WriteLine(path); - - } - - string MakePathGooder(string path) - { - string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; - string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); - - return gooderPath; - } - - } -} \ No newline at end of file diff --git a/Registry Test/Registry Test.csproj b/Registry Test/Registry Test.csproj deleted file mode 100644 index f572203..0000000 --- a/Registry Test/Registry Test.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Exe - net8.0 - Registry_Test - enable - enable - - - - - - - diff --git a/Registry Test/Registry Test.sln b/Registry Test/Registry Test.sln deleted file mode 100644 index f7c273e..0000000 --- a/Registry Test/Registry Test.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34316.72 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registry Test", "Registry Test.csproj", "{EEC84C97-C986-416A-BDEB-626880AED9B1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EEC84C97-C986-416A-BDEB-626880AED9B1}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {44FB9D92-1196-4B13-8ED6-11D05DB89AFA} - EndGlobalSection -EndGlobal diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index 7a69846..04bd19b 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -12,19 +12,8 @@ const string steamLibraryFolders = @"Program Files (x86)\Steam\steamapps\libraryfolders.vdf"; // default values -var gameDirs = new List() { - //@"*:\Program Files (x86)\Steam\steamapps\common", - //@"*:\XboxGames", @"*:\Program Files\EA Games", - //@"*:\Program Files\Epic Games\", - //@"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" -}; - -var registryDir = new List() -{ - @"SOFTWARE\Wow6432Node\Valve\Steam", - @"SOFTWARE\Valve\Steam" - //Other installer registry paths... -}; +var gameDirs = new List(); +var registryDir = new List(); var exclusionWords = new List() { "Steam" }; var exeExclusionWords = new List() { "Steam", "Cleanup", "DX", "Uninstall", "Touchup", "redist", "Crash", "Editor" }; @@ -68,203 +57,205 @@ // options handler rootCommand.SetHandler((addlDirectories, addlExeExclusionWords, sunshineConfigLocation, forceUpdate, removeUninstalled) => { - gameDirs.AddRange(addlDirectories); - exeExclusionWords.AddRange(addlExeExclusionWords); - var sunshineAppsJson = sunshineConfigLocation; - var sunshineRootFolder = Path.GetDirectoryName(sunshineAppsJson); +gameDirs.AddRange(addlDirectories); +exeExclusionWords.AddRange(addlExeExclusionWords); +var sunshineAppsJson = sunshineConfigLocation; +var sunshineRootFolder = Path.GetDirectoryName(sunshineAppsJson); - if (!File.Exists(sunshineAppsJson)) - { - Logger.Log($"Could not find Sunshine Apps config at specified path: {sunshineAppsJson}", LogLevel.Error); - return; - } - var sunshineAppInstance = JsonConvert.DeserializeObject(File.ReadAllText(sunshineAppsJson)); - var gamesAdded = 0; - var gamesRemoved = 0; +if (!File.Exists(sunshineAppsJson)) +{ + Logger.Log($"Could not find Sunshine Apps config at specified path: {sunshineAppsJson}", LogLevel.Error); + return; +} +var sunshineAppInstance = JsonConvert.DeserializeObject(File.ReadAllText(sunshineAppsJson)); +var gamesAdded = 0; +var gamesRemoved = 0; - if (removeUninstalled) +if (removeUninstalled) +{ + for (int i = sunshineAppInstance.apps.Count() - 1; i >= 0; i--) //keep tolist so we can remove elements while iterating on the "copy" { - for (int i = sunshineAppInstance.apps.Count() - 1; i >= 0; i--) //keep tolist so we can remove elements while iterating on the "copy" + var existingApp = sunshineAppInstance.apps[i]; + if (existingApp != null) { - var existingApp = sunshineAppInstance.apps[i]; - if (existingApp != null) + var exeStillExists = existingApp.cmd == null && existingApp.detached == null || + existingApp.cmd != null && File.Exists(existingApp.cmd) || + existingApp.detached != null && existingApp.detached.Any(detachedCommand => + { + return detachedCommand == null || + !detachedCommand.Contains("exe") || + detachedCommand != null && detachedCommand.EndsWith("exe") && File.Exists(detachedCommand); + }); + if (!exeStillExists) { - var exeStillExists = existingApp.cmd == null && existingApp.detached == null || - existingApp.cmd != null && File.Exists(existingApp.cmd) || - existingApp.detached != null && existingApp.detached.Any(detachedCommand => - { - return detachedCommand == null || - !detachedCommand.Contains("exe") || - detachedCommand != null && detachedCommand.EndsWith("exe") && File.Exists(detachedCommand); - }); - if (!exeStillExists) - { - Logger.Log($"{existingApp.name} no longer has an exe, removing from apps config..."); - sunshineAppInstance.apps.RemoveAt(i); - gamesRemoved++; - } + Logger.Log($"{existingApp.name} no longer has an exe, removing from apps config..."); + sunshineAppInstance.apps.RemoveAt(i); + gamesRemoved++; } } } +} - if (sunshineAppInstance == null) +if (sunshineAppInstance == null) +{ + Logger.Log($"Sunshite app list is null", LogLevel.Error); + return; +} + +void ScanFolder(string folder) +{ + Logger.Log($"Scanning for games in {folder}..."); + var di = new DirectoryInfo(folder); + if (!di.Exists) { - Logger.Log($"Sunshite app list is null", LogLevel.Error); + Logger.Log($"Directory for platform {di.Name} does not exist, skipping...", LogLevel.Warning); return; } - - void ScanFolder(string folder) + foreach (var gameDir in di.GetDirectories()) { - Logger.Log($"Scanning for games in {folder}..."); - var di = new DirectoryInfo(folder); - if (!di.Exists) + Logger.Log($"Looking for game exe in {gameDir}..."); + var gameName = gameDir.Name; + if (exclusionWords.Any(ew => gameName.Contains(ew))) { - Logger.Log($"Directory for platform {di.Name} does not exist, skipping...", LogLevel.Warning); - return; + Logger.Log($"Skipping {gameName} as it was an excluded word match..."); + continue; } - foreach (var gameDir in di.GetDirectories()) + var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories) + .OrderBy(f => new FileInfo(f).Length) + .FirstOrDefault(exefile => { - Logger.Log($"Looking for game exe in {gameDir}..."); - var gameName = gameDir.Name; - if (exclusionWords.Any(ew => gameName.Contains(ew))) - { - Logger.Log($"Skipping {gameName} as it was an excluded word match..."); - continue; - } - var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories).FirstOrDefault(exefile => - { - var exeName = new FileInfo(exefile).Name.ToLower(); - return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); - }); - if (string.IsNullOrEmpty(exe)) - { - Logger.Log($"EXE could not be found for game '{gameName}'", LogLevel.Warning); - continue; - } + var exeName = new FileInfo(exefile).Name.ToLower(); + return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); + }); + if (string.IsNullOrEmpty(exe)) + { + Logger.Log($"EXE could not be found for game '{gameName}'", LogLevel.Warning); + continue; + } - var existingApp = sunshineAppInstance.apps.FirstOrDefault(g => g.cmd == exe || g.name == gameName); - if (forceUpdate || existingApp == null) + var existingApp = sunshineAppInstance.apps.FirstOrDefault(g => g.cmd == exe || g.name == gameName); + if (forceUpdate || existingApp == null) + { + if (exe.Contains("gamelaunchhelper.exe")) { - if (exe.Contains("gamelaunchhelper.exe")) + //xbox game pass game + existingApp = new SunshineApp() { - //xbox game pass game - existingApp = new SunshineApp() - { - name = gameName, - detached = new List() + name = gameName, + detached = new List() { exe }, - workingdir = "" - }; - } - else - { - existingApp = new SunshineApp() - { - name = gameName, - cmd = exe, - workingdir = "" - }; - } - string coversFolderPath = sunshineRootFolder + "/covers/"; - string fullPathOfCoverImage = ImageScraper.SaveIGDBImageToCoversFolder(gameName, coversFolderPath).Result; - if (!string.IsNullOrEmpty(fullPathOfCoverImage)) - { - existingApp.imagepath = fullPathOfCoverImage; - } - else + workingdir = "" + }; + } + else + { + existingApp = new SunshineApp() { - Logger.Log("Failed to find cover image for " + gameName, LogLevel.Warning); - } - gamesAdded++; - Logger.Log($"Adding new game to Sunshine apps: {gameName} - {exe}"); - sunshineAppInstance.apps.Add(existingApp); + name = gameName, + cmd = exe, + workingdir = "" + }; + } + string coversFolderPath = sunshineRootFolder + "/covers/"; + string fullPathOfCoverImage = ImageScraper.SaveIGDBImageToCoversFolder(gameName, coversFolderPath).Result; + if (!string.IsNullOrEmpty(fullPathOfCoverImage)) + { + existingApp.imagepath = fullPathOfCoverImage; } else { - Logger.Log($"Found existing Sunshine app for {gameName} already!: " + (existingApp.cmd ?? existingApp.detached.FirstOrDefault() ?? existingApp.name).Trim()); + Logger.Log("Failed to find cover image for " + gameName, LogLevel.Warning); } + gamesAdded++; + Logger.Log($"Adding new game to Sunshine apps: {gameName} - {exe}"); + sunshineAppInstance.apps.Add(existingApp); + } + else + { + Logger.Log($"Found existing Sunshine app for {gameName} already!: " + (existingApp.cmd ?? existingApp.detached.FirstOrDefault() ?? existingApp.name).Trim()); } - Console.WriteLine(""); //blank line to separate platforms } + Console.WriteLine(""); //blank line to separate platforms +} - string MakePathGooder(string path) - { - string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; - string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); +string windowsPathConvert(string path) +{ + string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; + string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); - return gooderPath; - } + return gooderPath; +} - void RegistrySearch() +void RegistrySearch() +{ + foreach (var path in registryDir) { - foreach (var path in registryDir) + if (path.ToLower().Contains("steam")) { - if (path.ToLower().Contains("steam")) + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); + if (steamRegistry.GetValue("SteamPath") != null) { - RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = windowsPathConvert(temp); + gameDirs.Add(temp); + } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry.GetValue("SteamPath") != null) { string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); + temp = windowsPathConvert(temp); gameDirs.Add(temp); } - else - { - steamRegistry = Registry.CurrentUser.OpenSubKey(path); - if (steamRegistry != null && steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = MakePathGooder(temp); - gameDirs.Add(temp); - } - } } - /*else if (path contains other installer keywords) - { - - }*/ } } +} - var logicalDrives = DriveInfo.GetDrives(); - var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); +var logicalDrives = DriveInfo.GetDrives(); +var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); - if (OperatingSystem.IsWindows()) - { - gameDirs = new List +if (OperatingSystem.IsWindows()) +{ + gameDirs = new List { @"*:\Program Files (x86)\Steam\steamapps\common", - @"*:\XboxGames", + @"*:\XboxGames", @"*:\Program Files\EA Games", @"*:\Program Files\Epic Games\", @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" - //Other common directories }; - bool isSteamLibraryFound = false; - foreach (var drive in logicalDrives) + bool isSteamLibraryFound = false; + foreach (var drive in logicalDrives) + { + var libraryFoldersPath = drive.Name + steamLibraryFolders; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) { - var libraryFoldersPath = drive.Name + steamLibraryFolders; - var file = new FileInfo(libraryFoldersPath); - if (!file.Exists) - { - Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); + continue; + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) continue; - } - var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); - foreach (var library in libraries.Value) - { - if (library is not VProperty libProp) - continue; - gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); - isSteamLibraryFound = true; + gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); + isSteamLibraryFound = true; } } if (!isSteamLibraryFound) { + var registryDir = new List() + { + @"SOFTWARE\Wow6432Node\Valve\Steam", + @"SOFTWARE\Valve\Steam" + }; RegistrySearch(); } } @@ -275,12 +266,10 @@ void RegistrySearch() { var linuxPaths = new List() { - //Conflicting data on whether it's SteamApps or steamapps so here's both @"/.local/share/Steam/SteamApps/common", @"/.local/share/Steam/steamapps/common", @"/.local/share/Steam/SteamApps/compatdata", @"/.local/share/Steam/steamapps/compatdata" - //Other common directories (rockstar, epic, etc) }; var libraryFoldersPath = userInfo + @"/.local/share/Steam/steamapps/libraryfolders"; @@ -313,7 +302,6 @@ void RegistrySearch() var macOSPaths = new List() { @"/Library/Application Support/Steam/SteamApps/common" - //Other common directories (rockstar, epic, etc) }; var libraryFoldersPath = userInfo + @"/Library/Application Support/Steam/SteamApps/libraryfolders"; var file = new FileInfo(libraryFoldersPath); From ff676aad8b8f70d7fb5fc96156a6b06b5dc0ca62 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Fri, 1 Dec 2023 17:11:02 -0800 Subject: [PATCH 13/15] Fixed issues brought up in PR - some formatting fixes --- SunshineGameFinder/Program.cs | 294 +++++++++++++++++----------------- 1 file changed, 150 insertions(+), 144 deletions(-) diff --git a/SunshineGameFinder/Program.cs b/SunshineGameFinder/Program.cs index 04bd19b..1b8e4e9 100644 --- a/SunshineGameFinder/Program.cs +++ b/SunshineGameFinder/Program.cs @@ -57,198 +57,201 @@ // options handler rootCommand.SetHandler((addlDirectories, addlExeExclusionWords, sunshineConfigLocation, forceUpdate, removeUninstalled) => { -gameDirs.AddRange(addlDirectories); -exeExclusionWords.AddRange(addlExeExclusionWords); -var sunshineAppsJson = sunshineConfigLocation; -var sunshineRootFolder = Path.GetDirectoryName(sunshineAppsJson); + gameDirs.AddRange(addlDirectories); + exeExclusionWords.AddRange(addlExeExclusionWords); + var sunshineAppsJson = sunshineConfigLocation; + var sunshineRootFolder = Path.GetDirectoryName(sunshineAppsJson); -if (!File.Exists(sunshineAppsJson)) -{ - Logger.Log($"Could not find Sunshine Apps config at specified path: {sunshineAppsJson}", LogLevel.Error); - return; -} -var sunshineAppInstance = JsonConvert.DeserializeObject(File.ReadAllText(sunshineAppsJson)); -var gamesAdded = 0; -var gamesRemoved = 0; + if (!File.Exists(sunshineAppsJson)) + { + Logger.Log($"Could not find Sunshine Apps config at specified path: {sunshineAppsJson}", LogLevel.Error); + return; + } + var sunshineAppInstance = JsonConvert.DeserializeObject(File.ReadAllText(sunshineAppsJson)); + var gamesAdded = 0; + var gamesRemoved = 0; -if (removeUninstalled) -{ - for (int i = sunshineAppInstance.apps.Count() - 1; i >= 0; i--) //keep tolist so we can remove elements while iterating on the "copy" + if (removeUninstalled) { - var existingApp = sunshineAppInstance.apps[i]; - if (existingApp != null) + for (int i = sunshineAppInstance.apps.Count() - 1; i >= 0; i--) //keep tolist so we can remove elements while iterating on the "copy" { - var exeStillExists = existingApp.cmd == null && existingApp.detached == null || - existingApp.cmd != null && File.Exists(existingApp.cmd) || - existingApp.detached != null && existingApp.detached.Any(detachedCommand => - { - return detachedCommand == null || - !detachedCommand.Contains("exe") || - detachedCommand != null && detachedCommand.EndsWith("exe") && File.Exists(detachedCommand); - }); - if (!exeStillExists) + var existingApp = sunshineAppInstance.apps[i]; + if (existingApp != null) { - Logger.Log($"{existingApp.name} no longer has an exe, removing from apps config..."); - sunshineAppInstance.apps.RemoveAt(i); - gamesRemoved++; + var exeStillExists = existingApp.cmd == null && existingApp.detached == null || + existingApp.cmd != null && File.Exists(existingApp.cmd) || + existingApp.detached != null && existingApp.detached.Any(detachedCommand => + { + return detachedCommand == null || + !detachedCommand.Contains("exe") || + detachedCommand != null && detachedCommand.EndsWith("exe") && File.Exists(detachedCommand); + }); + if (!exeStillExists) + { + Logger.Log($"{existingApp.name} no longer has an exe, removing from apps config..."); + sunshineAppInstance.apps.RemoveAt(i); + gamesRemoved++; + } } } } -} - -if (sunshineAppInstance == null) -{ - Logger.Log($"Sunshite app list is null", LogLevel.Error); - return; -} -void ScanFolder(string folder) -{ - Logger.Log($"Scanning for games in {folder}..."); - var di = new DirectoryInfo(folder); - if (!di.Exists) + if (sunshineAppInstance == null) { - Logger.Log($"Directory for platform {di.Name} does not exist, skipping...", LogLevel.Warning); + Logger.Log($"Sunshite app list is null", LogLevel.Error); return; } - foreach (var gameDir in di.GetDirectories()) + + void ScanFolder(string folder) { - Logger.Log($"Looking for game exe in {gameDir}..."); - var gameName = gameDir.Name; - if (exclusionWords.Any(ew => gameName.Contains(ew))) - { - Logger.Log($"Skipping {gameName} as it was an excluded word match..."); - continue; - } - var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories) - .OrderBy(f => new FileInfo(f).Length) - .FirstOrDefault(exefile => + Logger.Log($"Scanning for games in {folder}..."); + var di = new DirectoryInfo(folder); + if (!di.Exists) { - var exeName = new FileInfo(exefile).Name.ToLower(); - return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); - }); - if (string.IsNullOrEmpty(exe)) - { - Logger.Log($"EXE could not be found for game '{gameName}'", LogLevel.Warning); - continue; + Logger.Log($"Directory for platform {di.Name} does not exist, skipping...", LogLevel.Warning); + return; } - - var existingApp = sunshineAppInstance.apps.FirstOrDefault(g => g.cmd == exe || g.name == gameName); - if (forceUpdate || existingApp == null) + foreach (var gameDir in di.GetDirectories()) { - if (exe.Contains("gamelaunchhelper.exe")) + Logger.Log($"Looking for game exe in {gameDir}..."); + var gameName = gameDir.Name; + if (exclusionWords.Any(ew => gameName.Contains(ew))) { - //xbox game pass game - existingApp = new SunshineApp() - { - name = gameName, - detached = new List() - { - exe - }, - workingdir = "" - }; + Logger.Log($"Skipping {gameName} as it was an excluded word match..."); + continue; } - else + var exe = Directory.GetFiles(gameDir.FullName, "*.exe", SearchOption.AllDirectories) + .OrderBy(f => new FileInfo(f).Length) + .FirstOrDefault(exefile => { - existingApp = new SunshineApp() - { - name = gameName, - cmd = exe, - workingdir = "" - }; + var exeName = new FileInfo(exefile).Name.ToLower(); + return exeName == gameName.ToLower() || !exeExclusionWords.Any(ew => exeName.Contains(ew.ToLower())); + }); + if (string.IsNullOrEmpty(exe)) + { + Logger.Log($"EXE could not be found for game '{gameName}'", LogLevel.Warning); + continue; } - string coversFolderPath = sunshineRootFolder + "/covers/"; - string fullPathOfCoverImage = ImageScraper.SaveIGDBImageToCoversFolder(gameName, coversFolderPath).Result; - if (!string.IsNullOrEmpty(fullPathOfCoverImage)) + + var existingApp = sunshineAppInstance.apps.FirstOrDefault(g => g.cmd == exe || g.name == gameName); + if (forceUpdate || existingApp == null) { - existingApp.imagepath = fullPathOfCoverImage; + if (exe.Contains("gamelaunchhelper.exe")) + { + //xbox game pass game + existingApp = new SunshineApp() + { + name = gameName, + detached = new List() + { + exe + }, + workingdir = "" + }; + } + else + { + existingApp = new SunshineApp() + { + name = gameName, + cmd = exe, + workingdir = "" + }; + } + string coversFolderPath = sunshineRootFolder + "/covers/"; + string fullPathOfCoverImage = ImageScraper.SaveIGDBImageToCoversFolder(gameName, coversFolderPath).Result; + if (!string.IsNullOrEmpty(fullPathOfCoverImage)) + { + existingApp.imagepath = fullPathOfCoverImage; + } + else + { + Logger.Log("Failed to find cover image for " + gameName, LogLevel.Warning); + } + gamesAdded++; + Logger.Log($"Adding new game to Sunshine apps: {gameName} - {exe}"); + sunshineAppInstance.apps.Add(existingApp); } else { - Logger.Log("Failed to find cover image for " + gameName, LogLevel.Warning); + Logger.Log($"Found existing Sunshine app for {gameName} already!: " + (existingApp.cmd ?? existingApp.detached.FirstOrDefault() ?? existingApp.name).Trim()); } - gamesAdded++; - Logger.Log($"Adding new game to Sunshine apps: {gameName} - {exe}"); - sunshineAppInstance.apps.Add(existingApp); - } - else - { - Logger.Log($"Found existing Sunshine app for {gameName} already!: " + (existingApp.cmd ?? existingApp.detached.FirstOrDefault() ?? existingApp.name).Trim()); } + Console.WriteLine(""); //blank line to separate platforms } - Console.WriteLine(""); //blank line to separate platforms -} -string windowsPathConvert(string path) -{ - string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; - string gooderPath = temp.Replace('/', Path.DirectorySeparatorChar); + string WindowsPathConvert(string path) + { + string temp = string.Concat("*", $@"{path.AsSpan(1)}") + @"\steamapps\common"; + string windowsPath = temp.Replace('/', Path.DirectorySeparatorChar); - return gooderPath; -} + return windowsPath; + } -void RegistrySearch() -{ - foreach (var path in registryDir) + void RegistrySearch() { - if (path.ToLower().Contains("steam")) + foreach (var path in registryDir) { - RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); - if (steamRegistry.GetValue("SteamPath") != null) - { - string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = windowsPathConvert(temp); - gameDirs.Add(temp); - } - else + if (path.ToLower().Contains("steam")) { - steamRegistry = Registry.CurrentUser.OpenSubKey(path); + RegistryKey? steamRegistry = Registry.LocalMachine.OpenSubKey(path); if (steamRegistry.GetValue("SteamPath") != null) { string temp = steamRegistry.GetValue("SteamPath").ToString(); - temp = windowsPathConvert(temp); + temp = WindowsPathConvert(temp); gameDirs.Add(temp); } + else + { + steamRegistry = Registry.CurrentUser.OpenSubKey(path); + if (steamRegistry.GetValue("SteamPath") != null) + { + string temp = steamRegistry.GetValue("SteamPath").ToString(); + temp = WindowsPathConvert(temp); + gameDirs.Add(temp); + } + } } } } -} - -var logicalDrives = DriveInfo.GetDrives(); -var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); -if (OperatingSystem.IsWindows()) -{ - gameDirs = new List - { - @"*:\Program Files (x86)\Steam\steamapps\common", - @"*:\XboxGames", - @"*:\Program Files\EA Games", - @"*:\Program Files\Epic Games\", - @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" - }; + var logicalDrives = DriveInfo.GetDrives(); + var wildcatDriveLetter = new Regex(Regex.Escape(wildcatDrive)); - bool isSteamLibraryFound = false; - foreach (var drive in logicalDrives) + if (OperatingSystem.IsWindows()) { - var libraryFoldersPath = drive.Name + steamLibraryFolders; - var file = new FileInfo(libraryFoldersPath); - if (!file.Exists) - { - Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); - continue; - } - var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); - foreach (var library in libraries.Value) + gameDirs = new List + { + @"*:\Program Files (x86)\Steam\steamapps\common", + @"*:\XboxGames", + @"*:\Program Files\EA Games", + @"*:\Program Files\Epic Games\", + @"*:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games" + }; + + bool isSteamLibraryFound = false; + + //Search .vdf file for other directories where games might be installed; add to gameDir + foreach (var drive in logicalDrives) { - if (library is not VProperty libProp) + var libraryFoldersPath = drive.Name + steamLibraryFolders; + var file = new FileInfo(libraryFoldersPath); + if (!file.Exists) + { + Logger.Log($"libraryfolders.vdf not found on {file.DirectoryName}, skipping...", LogLevel.Warning); continue; + } + var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersPath)); + foreach (var library in libraries.Value) + { + if (library is not VProperty libProp) + continue; - gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); - isSteamLibraryFound = true; + gameDirs.Add($@"{libProp.Value.Value("path")}\steamapps\common"); + isSteamLibraryFound = true; + } } - } + //Search registry if no other directories found from libraryfolder.vdf if (!isSteamLibraryFound) { var registryDir = new List() @@ -272,6 +275,7 @@ void RegistrySearch() @"/.local/share/Steam/steamapps/compatdata" }; + //Search .vdf file for other directories where games might be installed; add to gameDir var libraryFoldersPath = userInfo + @"/.local/share/Steam/steamapps/libraryfolders"; var file = new FileInfo(libraryFoldersPath); if (!file.Exists) @@ -303,6 +307,8 @@ void RegistrySearch() { @"/Library/Application Support/Steam/SteamApps/common" }; + + //Search .vdf file for other directories where games might be installed; add to gameDir var libraryFoldersPath = userInfo + @"/Library/Application Support/Steam/SteamApps/libraryfolders"; var file = new FileInfo(libraryFoldersPath); if (!file.Exists) From b8e98c9dc506845af7662c6d8ca35f84550e4c81 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Fri, 1 Dec 2023 17:30:59 -0800 Subject: [PATCH 14/15] Hopefully actually fixed filesystem now --- FileWriter.cs => SunshineGameFinder/FileWriter.cs | 0 ImageScraper.cs => SunshineGameFinder/ImageScraper.cs | 0 Logger.cs => SunshineGameFinder/Logger.cs | 0 Program.cs => SunshineGameFinder/Program.cs | 0 {Properties => SunshineGameFinder/Properties}/launchSettings.json | 0 SunshineAppsConfig.cs => SunshineGameFinder/SunshineAppsConfig.cs | 0 .../SunshineGameFinder.csproj | 0 .../SunshineGameFinder.sln | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename FileWriter.cs => SunshineGameFinder/FileWriter.cs (100%) rename ImageScraper.cs => SunshineGameFinder/ImageScraper.cs (100%) rename Logger.cs => SunshineGameFinder/Logger.cs (100%) rename Program.cs => SunshineGameFinder/Program.cs (100%) rename {Properties => SunshineGameFinder/Properties}/launchSettings.json (100%) rename SunshineAppsConfig.cs => SunshineGameFinder/SunshineAppsConfig.cs (100%) rename SunshineGameFinder.csproj => SunshineGameFinder/SunshineGameFinder.csproj (100%) rename SunshineGameFinder.sln => SunshineGameFinder/SunshineGameFinder.sln (100%) diff --git a/FileWriter.cs b/SunshineGameFinder/FileWriter.cs similarity index 100% rename from FileWriter.cs rename to SunshineGameFinder/FileWriter.cs diff --git a/ImageScraper.cs b/SunshineGameFinder/ImageScraper.cs similarity index 100% rename from ImageScraper.cs rename to SunshineGameFinder/ImageScraper.cs diff --git a/Logger.cs b/SunshineGameFinder/Logger.cs similarity index 100% rename from Logger.cs rename to SunshineGameFinder/Logger.cs diff --git a/Program.cs b/SunshineGameFinder/Program.cs similarity index 100% rename from Program.cs rename to SunshineGameFinder/Program.cs diff --git a/Properties/launchSettings.json b/SunshineGameFinder/Properties/launchSettings.json similarity index 100% rename from Properties/launchSettings.json rename to SunshineGameFinder/Properties/launchSettings.json diff --git a/SunshineAppsConfig.cs b/SunshineGameFinder/SunshineAppsConfig.cs similarity index 100% rename from SunshineAppsConfig.cs rename to SunshineGameFinder/SunshineAppsConfig.cs diff --git a/SunshineGameFinder.csproj b/SunshineGameFinder/SunshineGameFinder.csproj similarity index 100% rename from SunshineGameFinder.csproj rename to SunshineGameFinder/SunshineGameFinder.csproj diff --git a/SunshineGameFinder.sln b/SunshineGameFinder/SunshineGameFinder.sln similarity index 100% rename from SunshineGameFinder.sln rename to SunshineGameFinder/SunshineGameFinder.sln From 514d71ce9b933ebe072a56ddd510c0e1bfe6bc30 Mon Sep 17 00:00:00 2001 From: mikednjoy Date: Fri, 1 Dec 2023 17:37:47 -0800 Subject: [PATCH 15/15] The PublishProfiles and .pubxml files were in the .gitignore --- .gitignore | 4 +-- .../PublishProfiles/ClickOnceProfile.pubxml | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml diff --git a/.gitignore b/.gitignore index 4f3be99..bd2449c 100644 --- a/.gitignore +++ b/.gitignore @@ -177,14 +177,14 @@ DocProject/Help/Html2 DocProject/Help/html # Click-Once directory -publish/ +#publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted -*.pubxml +#*.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to diff --git a/SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml b/SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml new file mode 100644 index 0000000..a5f0b02 --- /dev/null +++ b/SunshineGameFinder/Properties/PublishProfiles/ClickOnceProfile.pubxml @@ -0,0 +1,35 @@ + + + + + 1 + 1.6.0.* + True + Release + False + true + True + Disk + True + False + True + False + Any CPU + bin\publish\ + bin\publish\ + ClickOnce + False + True + win-x64 + True + (none) + False + net6.0 + False + Foreground + False + Publish.html + + \ No newline at end of file