diff --git a/osu.Framework.Android/AndroidGameHost.cs b/osu.Framework.Android/AndroidGameHost.cs index 54a0c35dc5..256b02f0f8 100644 --- a/osu.Framework.Android/AndroidGameHost.cs +++ b/osu.Framework.Android/AndroidGameHost.cs @@ -11,6 +11,7 @@ using osu.Framework.Android.Input; using osu.Framework.Configuration; using osu.Framework.Extensions; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Video; @@ -67,11 +68,9 @@ protected override IEnumerable CreateAvailableInputHandlers() => public override Storage GetStorage(string path) => new AndroidStorage(path, this); - public override IEnumerable UserStoragePaths => new[] - { + public override IEnumerable UserStoragePaths // not null as internal "external storage" is always available. - Application.Context.GetExternalFilesDir(string.Empty).AsNonNull().ToString(), - }; + => Application.Context.GetExternalFilesDir(string.Empty).AsNonNull().ToString().Yield(); public override bool OpenFileExternally(string filename) => false; diff --git a/osu.Framework/Platform/GameHost.cs b/osu.Framework/Platform/GameHost.cs index a0232673a4..8a2768e2b7 100644 --- a/osu.Framework/Platform/GameHost.cs +++ b/osu.Framework/Platform/GameHost.cs @@ -206,7 +206,9 @@ public abstract class GameHost : IIpcHost, IDisposable /// /// All valid user storage paths in order of usage priority. /// - public virtual IEnumerable UserStoragePaths => Environment.GetFolderPath(Environment.SpecialFolder.Personal).Yield(); + public virtual IEnumerable UserStoragePaths + // This is common to _most_ operating systems, with some specific ones overriding this value where a better option exists. + => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.Create).Yield(); /// /// The main storage as proposed by the host game. diff --git a/osu.Framework/Platform/Linux/LinuxGameHost.cs b/osu.Framework/Platform/Linux/LinuxGameHost.cs index d67da94aa8..03a94ab3f9 100644 --- a/osu.Framework/Platform/Linux/LinuxGameHost.cs +++ b/osu.Framework/Platform/Linux/LinuxGameHost.cs @@ -1,9 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; -using System.IO; using System.Linq; using SDL2; using osu.Framework.Input; @@ -35,22 +33,6 @@ protected override void SetupForRun() base.SetupForRun(); } - public override IEnumerable UserStoragePaths - { - get - { - string? xdg = Environment.GetEnvironmentVariable("XDG_DATA_HOME"); - - if (!string.IsNullOrEmpty(xdg)) - yield return xdg; - - yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share"); - - foreach (string path in base.UserStoragePaths) - yield return path; - } - } - protected override IWindow CreateWindow(GraphicsSurfaceType preferredSurface) => new SDL2DesktopWindow(preferredSurface); protected override ReadableKeyCombinationProvider CreateReadableKeyCombinationProvider() => new LinuxReadableKeyCombinationProvider(); diff --git a/osu.Framework/Platform/MacOS/MacOSGameHost.cs b/osu.Framework/Platform/MacOS/MacOSGameHost.cs index 1600b9af05..9b39b725d8 100644 --- a/osu.Framework/Platform/MacOS/MacOSGameHost.cs +++ b/osu.Framework/Platform/MacOS/MacOSGameHost.cs @@ -27,17 +27,11 @@ public override IEnumerable UserStoragePaths { get { - yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support"); - - string xdg = Environment.GetEnvironmentVariable("XDG_DATA_HOME"); - - if (!string.IsNullOrEmpty(xdg)) - yield return xdg; - - yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share"); - foreach (string path in base.UserStoragePaths) yield return path; + + // Some older builds of osu! incorrectly used ~/.local/share on macOS. + yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share"); } } diff --git a/osu.Framework/Platform/Windows/WindowsGameHost.cs b/osu.Framework/Platform/Windows/WindowsGameHost.cs index 2bae681b06..ae1db05b3f 100644 --- a/osu.Framework/Platform/Windows/WindowsGameHost.cs +++ b/osu.Framework/Platform/Windows/WindowsGameHost.cs @@ -28,9 +28,9 @@ public class WindowsGameHost : DesktopGameHost protected override ReadableKeyCombinationProvider CreateReadableKeyCombinationProvider() => new WindowsReadableKeyCombinationProvider(); - public override IEnumerable UserStoragePaths => - // on windows this is guaranteed to exist (and be usable) so don't fallback to the base/default. - Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).Yield(); + public override IEnumerable UserStoragePaths + // The base implementation returns %LOCALAPPDATA%, but %APPDATA% is a better default on Windows. + => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create).Yield(); public override bool CapsLockEnabled => Console.CapsLock;