fix error when Steam .vdf file doesn't exist

This commit is contained in:
Jesse Plamondon-Willard 2022-10-10 13:36:11 -04:00
parent 93a748996c
commit 474c76183b
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 9 additions and 1 deletions

View File

@ -7,6 +7,10 @@
_If needed, you can update to SMAPI 3.16.0 first and then install the latest version._ _If needed, you can update to SMAPI 3.16.0 first and then install the latest version._
--> -->
## Upcoming release
* For players:
* Fixed installer error on Windows if the Steam library folder exists but doesn't contain Steam's `.vdf` library data file.
## 3.17.0 ## 3.17.0
Released 09 October 2022 for Stardew Valley 1.5.6 or later. See [release highlights](https://www.patreon.com/posts/73090322). Released 09 October 2022 for Stardew Valley 1.5.6 or later. See [release highlights](https://www.patreon.com/posts/73090322).

View File

@ -264,8 +264,12 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
if (steamPath == null) if (steamPath == null)
return null; return null;
// get raw .vdf data // get .vdf file path
string libraryFoldersPath = Path.Combine(steamPath.Replace('/', '\\'), "steamapps\\libraryfolders.vdf"); string libraryFoldersPath = Path.Combine(steamPath.Replace('/', '\\'), "steamapps\\libraryfolders.vdf");
if (!File.Exists(libraryFoldersPath))
return null;
// read data
using FileStream fileStream = File.OpenRead(libraryFoldersPath); using FileStream fileStream = File.OpenRead(libraryFoldersPath);
VdfDeserializer deserializer = new(); VdfDeserializer deserializer = new();
dynamic libraries = deserializer.Deserialize(fileStream); dynamic libraries = deserializer.Deserialize(fileStream);