Skip to content

Commit

Permalink
Merge pull request #504 from dreamsyntax/feature/onedrive-detection
Browse files Browse the repository at this point in the history
Enhancement: Fallback to SysDriveRoot on Install if OneDrive detected
  • Loading branch information
Sewer56 authored Nov 30, 2024
2 parents 67ce4f6 + 5f892b8 commit b7629cb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion source/Reloaded.Mod.Installer.Lib/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </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;
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 b7629cb

Please sign in to comment.