mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
Adjust user storage paths for better cross-platform support
This commit is contained in:
@@ -11,6 +11,7 @@ using osu.Framework.Android.Graphics.Video;
|
||||
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 @@ namespace osu.Framework.Android
|
||||
|
||||
public override Storage GetStorage(string path) => new AndroidStorage(path, this);
|
||||
|
||||
public override IEnumerable<string> UserStoragePaths => new[]
|
||||
{
|
||||
public override IEnumerable<string> 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;
|
||||
|
||||
|
||||
@@ -206,7 +206,9 @@ namespace osu.Framework.Platform
|
||||
/// <summary>
|
||||
/// All valid user storage paths in order of usage priority.
|
||||
/// </summary>
|
||||
public virtual IEnumerable<string> UserStoragePaths => Environment.GetFolderPath(Environment.SpecialFolder.Personal).Yield();
|
||||
public virtual IEnumerable<string> 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();
|
||||
|
||||
/// <summary>
|
||||
/// The main storage as proposed by the host game.
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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 @@ namespace osu.Framework.Platform.Linux
|
||||
base.SetupForRun();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> 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();
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@@ -23,24 +21,6 @@ namespace osu.Framework.Platform.MacOS
|
||||
|
||||
protected override IWindow CreateWindow(GraphicsSurfaceType preferredSurface) => new MacOSWindow(preferredSurface);
|
||||
|
||||
public override IEnumerable<string> 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;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Clipboard CreateClipboard() => new MacOSClipboard();
|
||||
|
||||
protected override ReadableKeyCombinationProvider CreateReadableKeyCombinationProvider() => new MacOSReadableKeyCombinationProvider();
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace osu.Framework.Platform.Windows
|
||||
|
||||
protected override ReadableKeyCombinationProvider CreateReadableKeyCombinationProvider() => new WindowsReadableKeyCombinationProvider();
|
||||
|
||||
public override IEnumerable<string> 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<string> 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user