Skip to content

Commit

Permalink
Handle missing KSP2 exe
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Jul 2, 2023
1 parent 94690ea commit f5ca34d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Core/Games/KerbalSpaceProgram2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ public void RefreshVersions()
public List<GameVersion> KnownVersions => versions;

public GameVersion DetectVersion(DirectoryInfo where)
=> GameVersion.Parse(
FileVersionInfo.GetVersionInfo(
Path.Combine(where.FullName, "KSP2_x64.exe")).ProductVersion
?? versions.Last().ToString());
=> VersionFromFile(Path.Combine(where.FullName, "KSP2_x64.exe"));

private GameVersion VersionFromFile(string path)
=> File.Exists(path)
? GameVersion.Parse(
FileVersionInfo.GetVersionInfo(path).ProductVersion
?? versions.Last().ToString())
: null;

public string CompatibleVersionsFile => "compatible_game_versions.json";

Expand Down

0 comments on commit f5ca34d

Please sign in to comment.