From 474c76183b601dc9ebd238a9acb69cd71f598af0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 10 Oct 2022 13:36:11 -0400 Subject: [PATCH] fix error when Steam .vdf file doesn't exist --- docs/release-notes.md | 4 ++++ src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 7574d62b..9f50fafa 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -7,6 +7,10 @@ _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 Released 09 October 2022 for Stardew Valley 1.5.6 or later. See [release highlights](https://www.patreon.com/posts/73090322). diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs index 66465ffe..1d518738 100644 --- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs +++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs @@ -264,8 +264,12 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning if (steamPath == null) return null; - // get raw .vdf data + // get .vdf file path string libraryFoldersPath = Path.Combine(steamPath.Replace('/', '\\'), "steamapps\\libraryfolders.vdf"); + if (!File.Exists(libraryFoldersPath)) + return null; + + // read data using FileStream fileStream = File.OpenRead(libraryFoldersPath); VdfDeserializer deserializer = new(); dynamic libraries = deserializer.Deserialize(fileStream);