Skip to content

Commit

Permalink
Enhancement: Fallback to SysDriveRoot on Install
Browse files Browse the repository at this point in the history
Makes the Reloaded-II initial installation fallback to SysDriveRoot
(commonly C:\) if OneDrive is detected in the path to the user's
Desktop.
Resolves #477
  • Loading branch information
dreamsyntax committed Nov 29, 2024
1 parent 67ce4f6 commit 6b6084c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions source/Reloaded.Mod.Installer.Lib/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
/// </summary>
public class Settings
{
public string InstallLocation { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "Reloaded-II");
public string InstallLocation { get; set; } = Path.Combine(GetSafeInstallPath(), "Reloaded-II");
public bool IsManuallyOverwrittenLocation { get; set; }
public bool CreateShortcut { get; set; } = true;
public bool HideNonErrorGuiMessages { get; set; } = false;
public bool StartReloaded { get; set; } = true;

public Settings() { }

public static Settings GetSettings(string[] args)
{
var settings = new Settings();
Expand All @@ -30,4 +30,18 @@ public static Settings GetSettings(string[] args)

return settings;
}

private static string GetSafeInstallPath()
{
var installPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
if (installPath.Contains("OneDrive"))
{
var driveRoot = Path.GetPathRoot(Environment.SystemDirectory);
if (driveRoot == null)
// if for some reason we can't determine the root, fallback to Desktop
return installPath;
return driveRoot;
}
return installPath;
}
}

0 comments on commit 6b6084c

Please sign in to comment.