#nullable disable using System.IO; using StardewModdingAPI.Toolkit.Framework; namespace StardewModdingAPI.Installer.Framework { /// Manages paths for the SMAPI installer. internal class InstallerPaths { /********* ** Accessors *********/ /**** ** Main folders ****/ /// The directory path containing the files to copy into the game folder. public DirectoryInfo BundleDir { get; } /// The directory containing the installed game. public DirectoryInfo GameDir { get; } /// The directory into which to install mods. public DirectoryInfo ModsDir { get; } /**** ** Installer paths ****/ /// The full path to directory path containing the files to copy into the game folder. public string BundlePath => this.BundleDir.FullName; /// The full path to the backup API user settings folder, if applicable. public string BundleApiUserConfigPath { get; } /**** ** Game paths ****/ /// The full path to the directory containing the installed game. public string GamePath => this.GameDir.FullName; /// The full path to the directory into which to install mods. public string ModsPath => this.ModsDir.FullName; /// The full path to SMAPI's internal configuration file. public string ApiConfigPath { get; } /// The full path to the user's config overrides file. public string ApiUserConfigPath { get; } /// The full path to the installed game DLL. public string GameDllPath { get; } /// The full path to the installed SMAPI executable file. public string UnixSmapiExecutablePath { get; } /// The full path to the vanilla game launch script on Linux/macOS. public string VanillaLaunchScriptPath { get; } /// The full path to the installed SMAPI launch script on Linux/macOS before it's renamed. public string NewLaunchScriptPath { get; } /// The full path to the backed up game launch script on Linux/macOS after SMAPI is installed. public string BackupLaunchScriptPath { get; } /********* ** Public methods *********/ /// Construct an instance. /// The directory path containing the files to copy into the game folder. /// The directory path for the installed game. public InstallerPaths(DirectoryInfo bundleDir, DirectoryInfo gameDir) { // base paths this.BundleDir = bundleDir; this.GameDir = gameDir; this.ModsDir = new DirectoryInfo(Path.Combine(gameDir.FullName, "Mods")); this.GameDllPath = Path.Combine(gameDir.FullName, Constants.GameDllName); // launch scripts this.VanillaLaunchScriptPath = Path.Combine(gameDir.FullName, "StardewValley"); this.NewLaunchScriptPath = Path.Combine(gameDir.FullName, "unix-launcher.sh"); this.BackupLaunchScriptPath = Path.Combine(gameDir.FullName, "StardewValley-original"); this.UnixSmapiExecutablePath = Path.Combine(gameDir.FullName, "StardewModdingAPI"); // internal files this.BundleApiUserConfigPath = Path.Combine(bundleDir.FullName, "smapi-internal", "config.user.json"); this.ApiConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.json"); this.ApiUserConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.user.json"); } } }